fork download
  1. let butlast lst =
  2. (List.rev (List.tl (List.rev lst)))
  3.  
  4. let last lst =
  5. List.hd (List.rev lst)
  6.  
  7. let pascal n =
  8. List.fold_left (fun x y -> match y with
  9. 0 -> x
  10. | 1 -> x @ [[y; y]]
  11. | _ -> let lst = last x in
  12. x @ [1::((List.map2 (+) (butlast lst) (List.tl lst)) @ [1])])
  13. [[1]] (0::(List.init n (fun x -> x + 1)))
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
File "prog.ml", line 13, characters 15-24:
Error: Unbound value List.init
stdout
Standard output is empty