swap-when ( x y quot: ( x -- n ) quot: ( n n -- ? ) -- x' y' )


Vocabulary
combinators.extras

Inputs
xan object
yan object
quota quotation with stack effect ( x -- n )
quota quotation with stack effect ( n n -- ? )


Outputs
x'an object
y'an object


Definition


: swap-when
( x y quot: ( x -- n ) quot: ( n n -- ? ) -- x' y' )
[ [ [ 2dup ] 2curry ] dip [ bi@ ] curry compose ] dip
[ [ swap ] when ] compose compose call ; inline