Agenda | m@.n m@.v mv lv rv |
m@.n is a verb defined by the gerund m
with an agenda specified by n ;
that is, the verb represented by the train selected from m
by the indices n . If n is boxed, the train
is parenthesized accordingly. The case m@.v
uses the result of the verb v to perform the selection.
|
dorh=: +: ` -: @. (]>9:) Double or halve (Case statement) dorh " 0 primes=: 2 3 5 7 11 13 17 19 4 6 10 14 5.5 6.5 8.5 9.5 _:`%:`*: @. * "0 a=: 2 1 0 _1 _2 1.41421 1 _ 1 4 g=: +`-`* x=: 1 2 3 [ y=: 6 5 4 (x g@.2: y) 6 10 12 (] * <:) y=: 5 4 3 2 1 0 Basis of factorial 20 12 6 2 0 0 1:`(] * <:) @. (1: < ]) "0 y Case statement 20 12 6 2 1 1 1:`(] * $:@<:)@.(1: < ])"0 y Self-reference for recursion 120 24 6 2 1 1 +`-`*`% @. (1 0 3;2 0) (- + %) (* +) 3 +`-`*`% @. (1 0 3;2 0) 4 _12.8125 perm=: i.@i.@_2: ` ([: ,/ (0: ,. $:&.<:) {"2 1 \:"1@=@i.) @. * perm 3 0 1 2 0 2 1 1 0 2 1 2 0 2 0 1 2 1 0