: map-from ( ... seq quot: ( ... elt -- ... newelt ) i -- ... newseq )
pick map-from-as ; inline
+: map-if ( ... seq if-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) -- ... newseq )
+ '[ dup @ _ when ] map ; inline
+
<PRIVATE
: push-map-if ( ..a elt filter-quot: ( ..a elt -- ..b ? ) map-quot: ( ..a elt -- ..b newelt ) accum -- ..b )
: >string-list ( seq -- seq' )
[ "\"" 1surround ] map "," join ;
+: with-string-lines ( str quot -- str' )
+ [ string-lines ] dip map "\n" join ; inline
+
+: prepend-lines-with-spaces ( str -- str' )
+ [ " " prepend ] with-string-lines ;
+
: one? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
[ find ] 2keep rot [
[ 1 + ] 2dip find-from drop not
] if-empty ;
: change-last ( seq quot -- )
- [ drop length 1 - ] [ change-nth ] 2bi ; inline
+ [ index-of-last ] [ change-nth ] bi* ; inline
: change-last-unsafe ( seq quot -- )
- [ drop length 1 - ] [ change-nth-unsafe ] 2bi ; inline
+ [ index-of-last ] [ change-nth-unsafe ] bi* ; inline
: replicate-into ( ... seq quot: ( ... -- ... newelt ) -- ... )
over [ length ] 2dip '[ _ dip _ set-nth-unsafe ] each-integer ; inline
'[
_ [ sequence-index-operator-last find-last-integer ] keepd
index/element
- ] bounds-check-find ; inline
+ ] bounds-check-call ; inline
: find-last-index ( ... seq quot: ( ... elt i -- ... ? ) -- ... i elt )
- [ [ length 1 - ] keep ] dip find-last-index-from ; inline
+ [ index-of-last ] dip find-last-index-from ; inline
: map-find-last-index ( ... seq quot: ( ... elt index -- ... result/f ) -- ... result i elt )
[ find-last-index ] (map-find-index) ; inline
:: (start-all) ( seq subseq increment -- indices )
0
- [ seq subseq subsequence-starts-from dup ]
+ [ seq subseq subseq-index-from dup ]
[ [ increment + ] keep ] produce nip ;
: start-all ( seq subseq -- indices )