About 8 years ago, I made a multilingual dictionary to help you translate between programming languages (at the time, between C++, VB, JavaScript). I'm now tempted to start the same thing for Lisp<->ML.
Let f be a function of many variables. If the arguments you want to pass are in a list l, how do you apply f to the arguments?
Common Lisp:
(apply f l)
OCaml:
uncurry f l;;
If you have the arguments a, b, how do you apply f?
CL:
(funcall f a b)
Scheme:
(f a b)
OCaml:
f a b;;
oh, I need to be more careful about tuples vs lists.
Let f be a function of many variables. If the arguments you want to pass are in a list l, how do you apply f to the arguments?
Common Lisp:
(apply f l)
OCaml:
uncurry f l;;
If you have the arguments a, b, how do you apply f?
CL:
(funcall f a b)
Scheme:
(f a b)
OCaml:
f a b;;
oh, I need to be more careful about tuples vs lists.
(no subject)
Date: 2008-05-18 04:40 am (UTC)(no subject)
Date: 2008-05-18 05:52 am (UTC)(no subject)
Date: 2008-05-18 06:26 am (UTC)(no subject)
Date: 2008-05-18 06:14 am (UTC)(no subject)
Date: 2008-05-18 12:02 pm (UTC)yeah, they're not the same in a language with types :P
(no subject)
Date: 2008-05-19 04:30 pm (UTC)(no subject)
Date: 2008-05-20 06:18 am (UTC)but a better answer is that you don't really want to do this. since there's no way of generically describing the type of an n-tuple, you can only write f and g for each n, and since there's no way of describing the length of a list in its type, g will fail with an exception if applied to any list whose length is not n.
generally, if you have a list of things, you want to do parametric aggregate operations on them, like mapping over them or folding to produce some result. tuples are for passing fixed bits of data into and out of functions. different purposes, so you get different types.