Re: chapter 4 confusion

"Chingfan Tsao [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAOCiaG6+oYVLKVeuty5XXm6LYBnk36w04p+fYeH5T_9RWhLGbA@mail.gmail.com>
Hello Roelof:

There is something called Documentation, and I believe Christophe is quite
clear about what to do before asking around.

Instead of solving your confusions, which Christophe already did, I'll just
give the documentation here,
and I believe it is the right thing to do to refer to the doc before asking
around if you have similar confusions next time.

Here <https://ocaml.janestreet.com/ocaml-core/111.28.00/doc/core/> in the
Core Doc, you should find explanations about ln.channel.fold_lines;
Here <http://caml.inria.fr/pub/docs/manual-ocaml/> in the Standard OCaml
Doc and User's manual, you should find explanations about |>, in the Index
of values, to be more specific.

Good luck.

2014-11-07 4:22 GMT+08:00 Christophe Troestler
[email protected] [ocaml_beginners] <
[email protected]>:

>
>
> 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.
>  
>



-- 
曹竞帆
哈尔滨工业大学计算机科学与技术专业本科在读
哈尔滨工业大学IBMTC成员
Chingfan Tsao
Senior Student of Computer Science and Technology at HIT
Member of HIT IBMTC
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.