4

Why does 2(*i.)5 evaluate to 0 2 4 6 8 ?

It's clear that 2*i.5 does, but the () creates a hook and evaluating from right to left it seems we get

 (*i.)5  ==  0 5 10 15 20

and 2 won't act on that list -- so where am I going wrong ?

Synthetica
  • 920
  • 1
  • 8
  • 23
user1202733
  • 623
  • 4
  • 10

2 Answers2

6

2 (* i.) 5, is a dyadic hook, which translates to 2 * (i. 5).

(* i.) 5, is a monadic hook, which translates to 5 * (i. 5).

The dyadic hook, x (u v) y is equivalent to x u (v y), which is the same as x u v y.

The monadic hook, (u v) y is equivalent to y u (v y), which is the same as y u v y.

http://www.jsoftware.com/jwiki/Vocabulary/hook

Dane
  • 1,201
  • 8
  • 17
  • Good explanation. The book I was reading didn't explain these cases (even existed) and just jumped straight to an example. Now I know where to look ! – user1202733 Mar 27 '15 at 10:56
3

x (u v) y <--> x u (v y) for dyadic hooks.

A use might be to reshape y into the shape x as shown at http://www.jsoftware.com/jwiki/Vocabulary/hook

   [t=.i. 3 2
0 1
2 3
4 5

   2 3 ($ ,) t
0 1 2
3 4 5
bob
  • 4,282
  • 2
  • 22
  • 30