Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 (16:31)
From: Vincent Barichard <Vincent Barichard <Vincent.Barichard@i...>
Subject: [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.

For example :
If I have the function
	 let fourAdd x y z w = x + y + z + w;;

I'll can execute it with the next command line :
	 myFunctionCall fourAdd [1 ; 2 ; 3 ; 4];;

The hypothesis are :
- The Arg1 function is in curried form and all its arguments have the same
- The length of Arg2 is exactly the number of arguments needed by Arg1

I've tried the following code, but it doesn't work because the argument
nomProcedure has a different type at each call.

let rec runAlgoWithArgs nomProcedure liste_Args =
	match liste_Args with
		[] -> raise Exit
	|	[x] -> nomProcedure x
	|	x::xs -> runAlgoWithArgs (nomProcedure x) xs

Is anybody has an idea ??

Thanks for your help,


Vincent Barichard
Métaheuristiques et Optimisation Combinatoire
Faculté des Sciences d'Angers
Tel : 02 41 73 52 06
Bug reports:  FAQ:
To unsubscribe, mail  Archives: