 : each-index ( ... seq quot: ( ... elt index -- ... ) -- ... )
     (each-index) each-integer ; inline
 
-: interleave ( seq between quot -- )
+: interleave ( ... seq between quot: ( ... elt -- ... ) -- ... )
     pick empty? [ 3drop ] [
         [ [ drop first-unsafe ] dip call ]
         [ [ rest-slice ] 2dip [ bi* ] 2curry each ]

: reduce ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
    swapd each ; inline

: map-integers ( len quot exemplar -- newseq )
    [ over ] dip [ [ collect ] keep ] new-like ; inline

: map-as ( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )


: glue ( seq1 seq2 seq3 -- newseq ) swap 3append ; inline

: change-nth ( ..a i seq quot: ( ..a elt -- ..b newelt ) -- ..b )
    [ [ nth ] dip call ] 3keep drop set-nth ; inline

: min-length ( seq1 seq2 -- n ) [ length ] bi@ min ; inline
