tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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