Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Francois Pottier <francois.pottier@i...>
Subject: Re: [Caml-list] Function call with a list of parameters

On Tue, Dec 11, 2001 at 02:59:22PM -0800, Chris Hecker wrote:

> 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

The usual solution is as follows:

  # let uncurry g (x,y) = g x y;;
  val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c = <fun>
  # uncurry g (f());;
  - : int = 3

-- 
François Pottier
Francois.Pottier@inria.fr
http://pauillac.inria.fr/~fpottier/
-------------------
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