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 {
|
||||
;
|
||||
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 ;
|
||||
def itm
|
||||
while { this:next dup =itm null eq not } {
|
||||
|
@ -64,6 +73,14 @@ construct _Iter {
|
|||
enumerate { EnumerationIter | with this ;
|
||||
this EnumerationIter:new
|
||||
}
|
||||
nth { item | with idx this ;
|
||||
idx -- =idx
|
||||
while { idx 0 gt } {
|
||||
this:next;
|
||||
idx -- =idx
|
||||
}
|
||||
this:next
|
||||
}
|
||||
}
|
||||
|
||||
construct MapIter {
|
||||
|
|
Loading…
Add table
Reference in a new issue