Skip to content

Instantly share code, notes, and snippets.

@jmdeldin
Created May 8, 2015 23:17
Show Gist options
  • Save jmdeldin/8029ce7b65764bff72e3 to your computer and use it in GitHub Desktop.
Save jmdeldin/8029ce7b65764bff72e3 to your computer and use it in GitHub Desktop.
List summation
let sum lst =
let rec aux acc rest = match rest with
| [] -> acc
| x::xs -> aux (x+acc) xs in
aux 0 lst;;
sum [3;1;4;1;5;9];;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment