Skip to content

Instantly share code, notes, and snippets.

@prakhar1989
Created July 28, 2016 23:37
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 prakhar1989/01dd0be59cb92721f2f3caa31f747457 to your computer and use it in GitHub Desktop.
Save prakhar1989/01dd0be59cb92721f2f3caa31f747457 to your computer and use it in GitHub Desktop.
Hacker Rank Prologue
let (|>) v f = f v;;
let comp f g = (fun x -> f (g x));;
let read_ints () : int list =
let rec aux nums =
try let i = read_int () in aux (i :: nums)
with End_of_file -> nums
in
List.rev (aux [])
;;
let () =
read_ints ()
|> List.map (fun i -> i * i)
|> List.iter (fun i -> (print_endline (string_of_int i)))
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment