pattern matching with keyword function
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have "stumbled" on this simple function
let rec flatten = function
[] -> []
| l::r -> l @ flatten r
At first glance I asked myself why they don't use the last remaining
element of the list
then I see that the line
[] -> []
doesn't have any "|" at the beginning.
Could you explain we how does that works?
And maybe could you give me one or more links for informations/examples
on the patterns matching
with the function keywords.
Thanks
cedlemo