map-if ( ... seq if-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) -- ... newseq )


Vocabulary
sequences.extras

Inputs
seqa sequence
if-quotan object
map-quotan object


Outputs
newseqa sequence


Word description
A version of map where map-quot is applied only if if-quot returns true for a given element.

Definition


: map-if
( ... seq if-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) -- ... newseq )
[ [ [ dup ] ] dip compose ] dip [ when ] curry compose map ;
inline