Skip to content

Commit

Permalink
Format examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed May 17, 2024
1 parent 460d0ff commit 6436441
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/arrays/arrays.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
# Example array functions. This code is illustrative: prefer using the array
# stdlib functions `std.array.map` and `std.array.fold_right` instead.
let my_array_lib = {
map : forall a b. (a -> b) -> Array a -> Array b = fun f arr =>
map : forall a b. (a -> b) -> Array a -> Array b
= fun f arr =>
if arr == [] then
[]
else
let head = std.array.first arr in
let tail = std.array.drop_first arr in
[f head] @ map f tail,

fold : forall a b. (a -> b -> b) -> b -> Array a -> b = fun f first arr =>
fold : forall a b. (a -> b -> b) -> b -> Array a -> b
= fun f first arr =>
if arr == [] then
first
else
Expand Down

0 comments on commit 6436441

Please sign in to comment.