Re: pattern matching with keyword function

"cedlemo [email protected] [ocaml_beginners]" <[email protected]> Fri, 8 Apr 2016 12:36:07 +0200
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
 > In pattern matching, the first vertical bar is optional.
Look at this, it is "normal" not to have a bar after "function":

Thanks that is the principal information that I needed.

 > More info: try to start reading the fine manual, because once you 
mastered reading
type signatures you get authoritative information. First stop for more 
OCaml info
is ocaml.org

I have the "real worl ocaml" book and I know the main site too, the code 
I shown you came
from : https://github.com/ocaml/ocaml/blob/trunk/stdlib/list.ml

In the same file I have this function too:

let rec map f = function
     [] -> []
   | a::l -> let r = f a in r :: map f l

And I don't get something :

assuming we do something like that:
a_fn is a function
a_list is a two element list

map a_fn a_list

in the first call of the map function, we go through the line:
a::l -> let r = f a in r :: map f l

the first element is taken and we use it as an argument to the a_fn 
function. The
result is then added to the result of the instruction

map f l which trigger the line
     [] -> []

but it look like the a_fn is not applied to the last element.

What am I missing ?

Thanks for taking on your time in order to answer me.

Regards

cedlemo