English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Function call with a list of parameters
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-12-11 (22:55)
From: Chris Hecker <checker@d...>
Subject: Re: [Caml-list] Function call with a list of parameters

>I'm trying to construct a function which take two arguments :
>                Arg1 : a function, Arg2 : a list of parameters for the Arg1.
>This function will call the function in Arg1 with Arg2 as parameters.

This is slightly related to a feature I'd like that's easy to do in lisp, but I don't think there's a way to do it in ML-style languages:

I have a function that returns a tuple, and a function that takes two curried parameters.  I'd like to pass the results of the first to the second, without having to break up the tuple with fst and snd (or pattern matching).

let f () = (1,2)
let g x y = x + y

g (? f ())


let x,y = f () in
g x y

With lisp you can just "apply" and it works.  There's no way in caml to spread the arguments into a curried function application, however.


Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr