Skip to content

Instantly share code, notes, and snippets.

@eschaefer
Created February 27, 2019 18:27
Show Gist options
  • Save eschaefer/2427727e8ce899a240ad7acac36c8b21 to your computer and use it in GitHub Desktop.
Save eschaefer/2427727e8ce899a240ad7acac36c8b21 to your computer and use it in GitHub Desktop.
ReasonML 2D array reduce or fold_left
let nestedArray = [|[|1, 1|], [|1, 2|], [|1, 3|]|];
let _ = nestedArray |> Array.fold_left(Array.append, [||]) |> Js.log;
/* [1,1,1,2,1,3] */
let _ = nestedArray |> Js.Array.reduce(Js.Array.concat, [||]) |> Js.log;
/* [1,3,1,2,1,1] */
@eschaefer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment