Learing OCaml: Currying
01 Apr 2007 19:20 - (0) comments
Wikipedia defines Currying as:
..the technique of transforming a function that takes multiple arguments into a function that takes a single argument (the other arguments having been specified by the curry).
For example you can define a function in OCaml called multiply:
let multiply a b =
a * b
;;
You can simply call this function:
multiply 5 6;; (* result in 30 *)
You can also use this function to create other functions:
let double = multiply 2;;
let triple = multiply 3;;triple 8;; (* result in 24 *)
Comments
No comments allowed.