Skip to content

Instantly share code, notes, and snippets.

@xandkar
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save xandkar/8785059 to your computer and use it in GitHub Desktop.

Select an option

Save xandkar/8785059 to your computer and use it in GitHub Desktop.
$ ocaml
# List.map (fun x -> let rec f x = match x with 0 -> 1 | n -> n * f (n - 1) in f x) [1; 2; 3];;
- : int list = [1; 2; 6]
#
let rec f x = match x with 0 -> 1 | n -> n * f (n - 1);;
val f : int -> int = <fun>
#
List.map f [1; 2; 3];;
- : int list = [1; 2; 6]
#
let rec f = function 0 -> 1 | n -> n * f (n - 1);;
val f : int -> int = <fun>
#
List.map f [1; 2; 3];;
- : int list = [1; 2; 6]
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment