Is it used for dyadic hooks in J?

It seems to me that the dyadic hook has the same effect as the same verbs without parentheses, like

2 (+ #) 1 2 3
2 + # 1 2 3

      

They both produce the same result: 5

. What can I do with (+ #)

that I cannot do with + #

?

+3


source to share


2 answers


I think the big difference is that you can use hooks silently to create more complex verbs. The hook becomes a module that you can insert into a longer fork. Removing the brackets overrides the hook functionality.

   2 (+ #) 1 2 3
5

      

This allows me to lay out a list with two more zeros



   2 ((+ #){. ]) 1 2 3
1 2 3 0 0

      

This gives a different result

   2 (+ # {. ]) 1 2 3
3 4 5

      

+6


source


The diademic hook solves the composition "problem", where M stands for a monadic verb and D for a dyadic verb.

  M@D
  (D M)

      

The dyadic hook is more necessary than the monadic version, which is only a short cut for

  (] D M)

      

although a dyadic hook can also be modeled as

  ([ D M@:])

      



which is also an ambivalent expression. Example:

 (, *~)

      

monadically adds y and its square
dyadically, adds x and the product of x and y.

(oops, bob is right). Regular ambivalent verb with the above explanations.

 ([ , *~)

      

+1


source







All Articles