more iterator functions

This commit is contained in:
Daniella / Tove 2023-04-08 16:57:18 +02:00
parent 1dce63794b
commit d08daa5a62
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F

View file

@ -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 {