ML curried functions
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) :
Hope this helps.
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
Popular Topics
Advertisement