Skip to content

Instantly share code, notes, and snippets.

@davidpelaez
Created May 30, 2016 04:26
Show Gist options
  • Save davidpelaez/651319118a5ed46bd3021d8d59f5167e to your computer and use it in GitHub Desktop.
Save davidpelaez/651319118a5ed46bd3021d8d59f5167e to your computer and use it in GitHub Desktop.
open Core.Std;
let rec read_and_accumulate accum => {
let line = In_channel.input_line In_channel.stdin;
switch line {
| None => accum
| Some x => read_and_accumulate (accum +. Float.of_string x)
}
};
let () = printf "Total: %F\n" (read_and_accumulate 0.);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment