Re: chapter 4 confusion
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Organization | University of Mons |
| Message-ID | <20141106.212230.273915462830973350.Christophe.Troestler@umons.ac.be> |
Hi, Please understand that people on this list are giving their time to answer your questions and that we have many other things to do so 1. don't expect answers to be immediate, 2. be respectful by being up to the point but also by showing that you have done your part of the work. On Thu, 6 Nov 2014 08:49:48 +0100, Roelof Wobben [email protected] [ocaml_beginners] wrote: > > 1) What means ln.channel.fold_lines stdin ~init part means ? The text says "In_channel.fold_lines (similar to the function List.fold described in Chapter 3, Lists and Patterns), which reads through the lines one by one, calling the provided fold function for each line to update the accumulator." Can you precisely voice what is not clear? You must not only read chapter 3 but launch the toplevel, modify the code and experiment with it until you precisely understand what it does. > 2) What does the |> does exactly. I know chapter 2 does explain it > a little > bit but it's still not clear to me Again, did you experiment with the code in Ch. 2 until you fully understood it? x |> f is equivalent to f(x) except that the priority of the operator |> is different from function application (which is always performed first) so you can use less parenthesis: x+y |> f |> g is equivalent to g(f(x+y)) It also makes the "pipeline" processing "x+y" more "clear". > 3) What does ~cmp mean. This is just a named argument: ~name:value Here, it passes a comparison function (defining a total order) to the function sorting the lines. Best, C.