Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.32 KB | None | 0 0
  1. let rec cMap f = function
  2.     | [] -> [1]
  3.     | x::xs -> (f x)::(cMap f xs)
  4.  
  5. let paskalNext l = 1::(l |> List.pairwise |> cMap (fun (a, b) -> a+b))
  6.  
  7. let paskal n =
  8.     let rec paskal' n acc =
  9.        if n = 1 then acc
  10.        else paskal' (n-1) (paskalNext(acc.Head)::acc)
  11.     if n <= 0 then []
  12.     else paskal' n [[1]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement