Formatting O'Caml code

Started by
13 comments, last by smitty1276 16 years, 11 months ago
Can I replicate this using the function syntax?
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
Not in O'Caml. Caml Light proposes the fun keyword for this:

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]
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.
Cool, thanks. That actually helped enough that I can read the thread at least!

This topic is closed to new replies.

Advertisement