fork download
  1. let f lst =
  2. let rec loop x0 x1 xs acc = match xs with
  3. [] -> (x0 + x1)::acc
  4. | first::rest -> loop x1 first rest ((x0 + x1)::acc) in
  5. loop (List.hd lst) (List.nth lst 1) (List.tl (List.tl lst)) []
  6.  
  7. let last lst =
  8. List.hd (List.rev lst)
  9.  
  10. let pascal n =
  11. let rec loop n acc = match n with
  12. 0 -> [List.hd acc]
  13. | 1 -> acc
  14. | _ -> loop (n - 1) (acc @ [(1::((f (last acc)) @ [1]))]) in
  15. loop n [[1]; [1; 1]]
Success #stdin #stdout 0s 5472KB
stdin
Standard input is empty
stdout
Standard output is empty