diff options
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( [], |