Skip to content

Commit

Permalink
Minor changes to iter standard module
Browse files Browse the repository at this point in the history
  • Loading branch information
bamless committed Jul 7, 2024
1 parent 84c2c52 commit 26e5ddb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Binary file modified src/lib/core/iter.jsc
Binary file not shown.
17 changes: 12 additions & 5 deletions src/lib/core/iter.jsr
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class Iterable
return take(this, count)
end

fun takeWhile(predicate)
return takeWhile(this, predicate)
fun takeWhile(predicate, inclusive=false)
return takeWhile(this, predicate, inclusive)
end

fun flatten()
Expand All @@ -125,8 +125,12 @@ class Iterable
return sorted(this, comparator)
end

fun collect(collector, ...args)
return collector(this, ...args) if #args > 0 else collector(this)
fun apply(iterator, ...args)
return iterator(this, ...args) if #args > 0 else iterator(this)
end

fun collect(collector)
return collector(this)
end
end

Expand Down Expand Up @@ -544,9 +548,12 @@ fun take(iterable, count)
end
end

fun takeWhile(iterable, predicate)
fun takeWhile(iterable, predicate, inclusive=false)
for var e in iterable
if !predicate(e)
if inclusive
yield e
end
break
end
yield e
Expand Down

0 comments on commit 26e5ddb

Please sign in to comment.