In Python and Ruby (and others as well, I\'m sure). you can prefix an enumerable with *
(\"splat\") to use it as an argument list. For instance, in Python:
The uncurry function turns a function on two arguments into a function on a tuple. Lists would not work in general because of their requirement for homogeneity.
Yes, you can apply functions to tuples, using the tuple package. Check out, in particular, the uncurryN function, which handles up to 32-tuples:
Prelude Data.Tuple.Curry> (+) `uncurryN` (1, 2)
3
No, Haskell's type system doesn't like that. Check this similar question for more details:
How do I define Lisp’s apply in Haskell?
BTW, the splat operator you talk about is also known as the apply
function, commonly found on dynamical functional languages (like LISP and Javascript).