Skip to content

Instantly share code, notes, and snippets.

@hannesm

hannesm/my.ml Secret

Created November 10, 2018 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannesm/d6f5e6451fb558450f11228f5d8e0b0e to your computer and use it in GitHub Desktop.
Save hannesm/d6f5e6451fb558450f11228f5d8e0b0e to your computer and use it in GitHub Desktop.
sum
let rec sum xs =
match xs with
| [] -> 0 (* yield 0 if xs has the form [] *)
| x :: xs' -> x + sum xs';; (* recursive call if xs has the form x::xs' for suitable x and xs' *)
let rec sum = function
| [] -> 0 (* yield 0 if xs has the form [] *)
| x :: xs' -> x + sum xs';; (* recursive call if xs has the form x::xs' for suitable x and xs' *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment