From 9fd5575d2525bfecc509e6378af704a8e822b710 Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sat, 4 Dec 2021 15:00:01 +0100 Subject: Fix docs and usage for iterator.reduce --- src/gleam/iterator.gleam | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gleam/iterator.gleam b/src/gleam/iterator.gleam index 097e6c2..babebc6 100644 --- a/src/gleam/iterator.gleam +++ b/src/gleam/iterator.gleam @@ -920,16 +920,16 @@ pub fn group( /// This function acts similar to fold, but does not take an initial state. /// Instead, it starts from the first yielded element /// and combines it with each subsequent element in turn using the given function. -/// The function is called as f(current_element, accumulator). +/// The function is called as f(accumulator, current_element). /// /// Returns `Ok` to indicate a successful run, and `Error` if called on an empty iterator. /// /// ## Examples /// -/// > from_list([]) |> reduce(fn(x, y) { x + y }) +/// > from_list([]) |> reduce(fn(acc, x) { acc + x }) /// Error(Nil) /// -/// > from_list([1, 2, 3, 4, 5]) |> reduce(fn(x, y) { x + y }) +/// > from_list([1, 2, 3, 4, 5]) |> reduce(fn(acc, x) { acc + x }) /// Ok(15) /// pub fn reduce( -- cgit v1.2.3