Created
May 30, 2016 04:26
-
-
Save davidpelaez/651319118a5ed46bd3021d8d59f5167e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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