Contents
^: (Power) Conjunction
Applies verb u to its argument(s) multiple times.
(+:) 7 NB. "Double" (monadic verb) 14 (+: ^:2) 7 NB. "Double Double" 28 3 , 4 NB. "Append" (dyadic verb) 3 4 3 (, ^:9) 4 3 3 3 3 3 3 3 3 3 4
Common uses
1. Repeatedly running a verb, (eg. to save writing a for.-loop):
sufx=: 4 : 'y , x' '.' sufx 'mystring' mystring. '.' sufx ^:3 'mystring' mystring...
2. Conditionally running a verb (eg. to save writing an if.-statement):
sufx=: 4 : 'y , x' flag=: 1 '.' sufx ^:flag 'mystring' mystring. flag=: 0 '.' sufx ^:flag 'mystring' mystring
3. Executing a verb repeatedly until nothing changes (eg. to save writing a while.-loop):
chop=: 3 : 'if. ''.''={:y do. }:y else. y end.' NB. chop 1 trailing dot
NB. Or (c/f 2 above) you could write...
chop=: 3 : '}: ^:(''.''={:y) y' NB. chop 1 trailing dot
chop 'mystring'
mystring
chop 'mystring...'
mystring..
chop ^:_ 'mystring...' NB. chop trailing dot(s)
mystring4. Executing the obverse (==usually the inverse) of a (primitive) verb:
+: 14 NB. "Double" 28 (+: ^:_1) 14 NB. the obverse of "Double" is "Halve" 7
For a fuller treatment with further examples, see: JfC, Chapter 16.
See Also
Double (+:)
Entry in the J Dictionary for ^:
