Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Pascals-triangle/OCaml/pascals-triangle.ocaml
Normal file
10
Task/Pascals-triangle/OCaml/pascals-triangle.ocaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(* generate next row from current row *)
|
||||
let next_row row =
|
||||
List.map2 (+) ([0] @ row) (row @ [0])
|
||||
|
||||
(* returns the first n rows *)
|
||||
let pascal n =
|
||||
let rec loop i row =
|
||||
if i = n then []
|
||||
else row :: loop (i+1) (next_row row)
|
||||
in loop 0 [1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue