aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJechol Lee <mr.jechol@gmail.com>2020-08-14 15:58:57 +0900
committerLouis Pilfold <louis@lpil.uk>2020-08-14 11:59:46 +0100
commitd081016a6e42832156d99126255660b841be6883 (patch)
tree719eb2e4af572023fd7c2b6e85a716d9e6f74dc4
parent8e0cec5d29e1af956b9c4fce552b96319ad2a602 (diff)
downloadgleam_stdlib-d081016a6e42832156d99126255660b841be6883.tar.gz
gleam_stdlib-d081016a6e42832156d99126255660b841be6883.zip
iterator() -> continuation()
-rw-r--r--src/gleam/iterator.gleam18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gleam/iterator.gleam b/src/gleam/iterator.gleam
index 6489aa4..7283c15 100644
--- a/src/gleam/iterator.gleam
+++ b/src/gleam/iterator.gleam
@@ -108,11 +108,11 @@ pub fn from_list(list: List(element)) -> Iterator(element) {
// Consuming Iterators
fn do_fold(
- iterator: fn() -> Action(e),
+ continuation: fn() -> Action(e),
initial: acc,
f: fn(e, acc) -> acc,
) -> acc {
- case iterator() {
+ case continuation() {
Continue(element, iterator) -> do_fold(iterator, f(element, initial), f)
Stop -> initial
}
@@ -168,9 +168,9 @@ pub fn to_list(iterator: Iterator(element)) -> List(element) {
|> list.reverse
}
-fn do_take(iterator: fn() -> Action(e), desired: Int, acc: List(e)) -> List(e) {
+fn do_take(continuation: fn() -> Action(e), desired: Int, acc: List(e)) -> List(e) {
case desired > 0 {
- True -> case iterator() {
+ True -> case continuation() {
Continue(
element,
iterator,
@@ -201,13 +201,13 @@ pub fn take(from iterator: Iterator(e), up_to desired: Int) -> List(e) {
|> do_take(desired, [])
}
-fn do_drop(iterator: fn() -> Action(e), desired: Int) -> fn() -> Action(e) {
+fn do_drop(continuation: fn() -> Action(e), desired: Int) -> fn() -> Action(e) {
case desired > 0 {
- True -> case iterator() {
+ True -> case continuation() {
Continue(_, iterator) -> do_drop(iterator, desired - 1)
Stop -> fn() { Stop }
}
- False -> iterator
+ False -> continuation
}
}
@@ -262,9 +262,9 @@ pub fn map(over iterator: Iterator(a), with f: fn(a) -> b) -> Iterator(b) {
|> Iterator
}
-fn do_filter(iterator: fn() -> Action(e), predicate: fn(e) -> Bool) -> fn() -> Action(e) {
+fn do_filter(continuation: fn() -> Action(e), predicate: fn(e) -> Bool) -> fn() -> Action(e) {
fn() {
- case iterator() {
+ case continuation() {
Continue(e, iterator) -> case predicate(e) {
True -> Continue(e, do_filter(iterator, predicate))
False -> do_filter(iterator, predicate)()