tracks/fsharp/exercises/pascals-triangle/Example.fs in trackler-2.2.1.49 vs tracks/fsharp/exercises/pascals-triangle/Example.fs in trackler-2.2.1.50
- old
+ new
@@ -1,9 +1,13 @@
module PascalsTriangle
-
-let triangle rows =
- let row i =
- [1 .. i - 1]
- |> List.scan (fun acc j -> acc * (i - j) / j) 1
-
- [1..rows]
- |> List.map row
+
+let rows numberOfRows : int list list option =
+ match numberOfRows with
+ | r when r < 0 -> None
+ | _ ->
+ let row i =
+ [1 .. i - 1]
+ |> List.scan (fun acc j -> acc * (i - j) / j) 1
+
+ [1..numberOfRows]
+ |> List.map row
+ |> Some
\ No newline at end of file