Advertisement
pavelperc

pascal

Sep 18th, 2018
1,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.34 KB | None | 0 0
  1. let next L =
  2.     let l1 = L |> List.pairwise |> List.map (fun (a,b) -> a + b )
  3.     1::l1@[1]
  4.  
  5. next [1;3;3;1]
  6.  
  7. let pasc n =
  8.     let rec pascrev (n:int): list<list<int>> =
  9.         match n with
  10.         | 1 -> [[1;1]]
  11.         | _ -> match pascrev (n - 1) with
  12.                | x::xs as prev-> (next x)::prev
  13.     pascrev n |> List.rev
  14.  
  15. pasc 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement