let foo list1 list2 = match list1, list2 with [], [] -> [] | whatever;;
My attempts so far have ended up with the function always taking a single tuple as its argument, rather than two args.
Formatting O'Caml code
Can I replicate this using the function syntax?
Not in O'Caml. Caml Light proposes the fun keyword for this:
This, however, is not possible in O'Caml to the best of my knowledge. The manual itself uses the syntax you propose for matching two parameters together.
let frob = fun | [] [] -> [] | _ _ -> [];;
This, however, is not possible in O'Caml to the best of my knowledge. The manual itself uses the syntax you propose for matching two parameters together.
Good grief, that may be the ugliest, non-friendly syntax I've ever seen... but I'm intrigued. Where's the best place to learn about it, in case I ever decide to pick up a new, weird language?
[grin]
[grin]
The manual is probably not the best place. I learned the Caml Light language in a school course first, and the move to O'Caml is straightforward. If you can read French, you can read my course for the former.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement