diff --git a/iter.spl b/iter.spl index c5fd225..be56ef5 100644 --- a/iter.spl +++ b/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 {