diff options
author | Marcin Puc <marcin.e.puc@gmail.com> | 2021-03-16 22:34:36 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-03-21 12:46:10 +0000 |
commit | 8b4b6ae2f452f26d4517b170323bad2846eb7a81 (patch) | |
tree | 22135134285ce727f5d23979d9c9303f77229caa /src | |
parent | 6906334a71f1ee202c69b0c58596c550d2691061 (diff) | |
download | gleam_stdlib-8b4b6ae2f452f26d4517b170323bad2846eb7a81.tar.gz gleam_stdlib-8b4b6ae2f452f26d4517b170323bad2846eb7a81.zip |
Correct iterator documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/iterator.gleam | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gleam/iterator.gleam b/src/gleam/iterator.gleam index b506b78..6c16abe 100644 --- a/src/gleam/iterator.gleam +++ b/src/gleam/iterator.gleam @@ -47,7 +47,7 @@ fn do_unfold( /// Creates an iterator from a given function and accumulator. /// -/// The function is called on the accumulator and return either `Done`, +/// The function is called on the accumulator and returns either `Done`, /// indicating the iterator has no more elements, or `Next` which contains a /// new element and accumulator. The element is yielded by the iterator and the /// new accumulator is used with the function to compute the next element in @@ -94,7 +94,7 @@ pub fn repeat(x: element) -> Iterator(element) { repeatedly(fn() { x }) } -/// Creates an iterator the yields each element in a given list. +/// Creates an iterator that yields each element from the given list. /// /// ## Examples /// @@ -149,7 +149,7 @@ pub fn fold( } // TODO: test -/// Evaluates all elements in a given stream. This function is useful for when +/// Evaluates all elements emitted by the given iterator. This function is useful for when /// you wish to trigger any side effects that would occur when evaluating /// the iterator. /// @@ -157,7 +157,7 @@ pub fn run(iterator: Iterator(e)) -> Nil { fold(iterator, Nil, fn(_, _) { Nil }) } -/// Evaluates an iterator and return all the elements as a list. +/// Evaluates an iterator and returns all the elements as a list. /// /// If called on an iterator of infinite length then this function will never /// return. @@ -186,6 +186,7 @@ pub fn to_list(iterator: Iterator(element)) -> List(element) { /// > |> step /// > head /// 1 +/// /// > tail |> to_list /// [2, 3, 4] /// @@ -337,7 +338,7 @@ fn do_flatten( } } -/// Flattens an iterator of iterator of iterators, creating a new iterator. +/// Flattens an iterator of iterators, creating a new iterator. /// /// This function does not evaluate the elements of the iterator, the /// computation is performed when the iterator is later run. |