Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created April 26, 2015 13:45
Show Gist options
  • Select an option

  • Save SteveGilham/8951080739d59359fa35 to your computer and use it in GitHub Desktop.

Select an option

Save SteveGilham/8951080739d59359fa35 to your computer and use it in GitHub Desktop.
exception EmptyList of string
let rec folds g x
= match x
with [] -> raise (EmptyList "folds")
| [x] -> x
| h::t -> g h (folds g t)
try folds (fun x y -> x + y) []
with EmptyList m -> stdout.WriteLine(m);
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment