ML curried functions

Started by
1 comment, last by GameDev.net 18 years, 2 months ago
can someone please explain how curried functions work.
Advertisement
Basically, currying is where a function that takes multiple arguments is turned into a function which takes one argument and returns a function which takes the next argument, which returns a function that takes the next argument, and so forth.
In case you need an example (OCaml dialect) :

let add = fun a -> fun b -> a + b;;(* bind add_one to the function returned by add, which has the signature * int -> int. That is, it takes an integer parameter and returns an integer. *)let add_one = add 1;;add_one 2;; (* yields 3 *)



Hope this helps.

This topic is closed to new replies.

Advertisement