more iterator functions
This commit is contained in:
parent
1dce63794b
commit
d08daa5a62
1 changed files with 17 additions and 0 deletions
17
iter.spl
17
iter.spl
|
@ -1,6 +1,15 @@
|
||||||
|
|
||||||
construct _Iter {
|
construct _Iter {
|
||||||
;
|
;
|
||||||
|
next-chunk { [item] | with amount this ;
|
||||||
|
def i 0 =i
|
||||||
|
def arr amount anew =arr
|
||||||
|
while { i amount lt } {
|
||||||
|
(this:next i arr:set;)
|
||||||
|
i ++ =i
|
||||||
|
}
|
||||||
|
arr
|
||||||
|
}
|
||||||
foreach { | with callable this ;
|
foreach { | with callable this ;
|
||||||
def itm
|
def itm
|
||||||
while { this:next dup =itm null eq not } {
|
while { this:next dup =itm null eq not } {
|
||||||
|
@ -64,6 +73,14 @@ construct _Iter {
|
||||||
enumerate { EnumerationIter | with this ;
|
enumerate { EnumerationIter | with this ;
|
||||||
this EnumerationIter:new
|
this EnumerationIter:new
|
||||||
}
|
}
|
||||||
|
nth { item | with idx this ;
|
||||||
|
idx -- =idx
|
||||||
|
while { idx 0 gt } {
|
||||||
|
this:next;
|
||||||
|
idx -- =idx
|
||||||
|
}
|
||||||
|
this:next
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
construct MapIter {
|
construct MapIter {
|
||||||
|
|
Loading…
Add table
Reference in a new issue