Archive for October, 2006

Oct 25 2006

Ocaml Quiz

Published by tim under coding

Quick, an Ocaml quiz:
- What is the best way to write a summation function?
let sum a = List.fold_left (fun x total -> x+total) 0 a
or
let sum a = List.fold_right (fun x total -> x+total) a 0
- What is the best way to write this function?
let plus1 a = List.map (fun x -> x+1) a
…or…
let plus1 [...]

One response so far