context function 3: op-if
op-if:
description:
op-if(condition, operator1, operator2) input-seq
op-if condition evaluates to |yes> or |true> then apply operator1 to input-seq
else apply operator2 to input-seq
NB: the python version of if() is much uglier and clunkier.
It is now implemented as value-if()
examples:
-- just define a couple of abstract operators:
op1 (*) #=> |op1:> __ smerge[", "] |__self>
op2 (*) #=> |op2:> __ smerge[", "] |__self>
-- then apply it:
op-if(|yes>, |op: op1>, |op: op2>) ssplit |abc>
|op1: a, b, c>
op-if(|no>, |op: op1>, |op: op2>) ssplit |abc>
|op2: a, b, c>
see also:
value-if
Home