diff options
author | Julian Schurhammer <julian.schurhammer@gmail.com> | 2023-12-04 11:49:57 +1300 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-12-09 09:57:32 +0000 |
commit | eaa795fe6597f8bd9b8b95045f293ff5e81dd96d (patch) | |
tree | f149743a18c9121ddef75ea9c100ca2b3f721daa /src | |
parent | e261f0fde8fb3b86830cc0fc5db039378cfb3d9e (diff) | |
download | gleam_stdlib-eaa795fe6597f8bd9b8b95045f293ff5e81dd96d.tar.gz gleam_stdlib-eaa795fe6597f8bd9b8b95045f293ff5e81dd96d.zip |
list.index_map: change callback signature
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/list.gleam | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index a5cffa9..5f62e58 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -442,14 +442,14 @@ pub fn map_fold( fn do_index_map( list: List(a), - fun: fn(Int, a) -> b, + fun: fn(a, Int) -> b, index: Int, acc: List(b), ) -> List(b) { case list { [] -> reverse(acc) [x, ..xs] -> { - let acc = [fun(index, x), ..acc] + let acc = [fun(x, index), ..acc] do_index_map(xs, fun, index + 1, acc) } } @@ -464,11 +464,11 @@ fn do_index_map( /// ## Examples /// /// ```gleam -/// > index_map(["a", "b"], fn(i, x) { #(i, x) }) +/// > index_map(["a", "b"], fn(x, i) { #(i, x) }) /// [#(0, "a"), #(1, "b")] /// ``` /// -pub fn index_map(list: List(a), with fun: fn(Int, a) -> b) -> List(b) { +pub fn index_map(list: List(a), with fun: fn(a, Int) -> b) -> List(b) { do_index_map(list, fun, 0, []) } @@ -1718,7 +1718,7 @@ pub fn permutations(l: List(a)) -> List(List(a)) { [] -> [[]] _ -> l - |> index_map(fn(i_idx, i) { + |> index_map(fn(i, i_idx) { l |> index_fold( [], |