1 USING: kernel sequences sequences.private math ;
6 : iterate-seq ( seq quot -- i seq quot )
7 [ [ length ] keep ] dip ; inline
9 : (map-next) ( i seq quot -- )
10 ! this uses O(n) more bounds checks than is really necessary
11 [ [ [ 1+ ] dip ?nth ] 2keep nth-unsafe ] dip call ; inline
15 : each-next ( seq quot: ( next-elt elt -- ) -- )
16 iterate-seq [ (map-next) ] 2curry each-integer ; inline
18 : map-next ( seq quot: ( next-elt elt -- newelt ) -- newseq )
19 over dup length swap new-sequence [
20 iterate-seq [ (map-next) ] 2curry
21 ] dip [ collect ] keep ; inline