If I had the power
^: (if)
The power conjunction has the obvious use of applying a verb repeatedly. Thus, if double=.+: , then double 3 is 6. We can use the power conjunction to specify an arbitrary number of applications: thrice=.^:3: double thrice 5 40 The number of times a verb is to be applied can be zero. This suggests a way to apply a verb conditionally. reverse=.|. if=.^: tlh=.{:<{. NB. tail less than head reverse if tlh 4 0 1 3 2 2 3 1 0 4 reverse if tlh 2 1 0 3 4 2 1 0 3 4 halve=.-: even=.-.@(2:|]) NB. not 2 residue halve if even 19 19 halve if even 160 80 |