views:

128

answers:

2

I'm just starting to try to pick up the J language, and am confused by the following:

   1 2 +/@{ i.4
1 2
   +/ 1 2 { i.4
3

when in the documentation for @ it says: "x u@v y ↔ u x v y"

I assume I'm just mistaking one part of speech for another, but can't figure it out

also, how do I tell what type of speech a name is?

A: 

Ah, I think I may have figured it out, I need to use @: instead of @

   1 2 +/@:{ i.4
3

which is what I wanted. Guess I'm going to have to read up some more on rank, which is the only difference between @ and @:

cobbal
How did your study of rank turn out, cobbal? Once I finally understood it, it was a pretty eye-opening experience.
Gregory Higley
+2  A: 
   NB. u b. 0 returns the rank of u
   NB. the rank of a verb determines the arguments it applies to at a time
   NB. monadic + y applies to atoms; dyadic x + y applies to pairs of atoms
   + b. 0
0 0 0
   NB. monadic +/ y and dyadic x +/ y apply to anything (unbounded rank)
   +/ b. 0
_ _ _
   NB. monadic { y applies to arrays of atoms;
   NB. dyadic x { y applies to pairs of atoms and anything
   { b. 0
1 0 _
   NB. u @ v has the rank of v
   +/@{ b. 0
1 0 _
   NB. since 1 2 { i.4 returns atoms at a time, +/ works on atoms
   +/"0 [ 1 2 { i.4
1 2
   NB. u @: v has unbounded rank
   +/@:{ b. 0
_ _ _
   NB. +/ applies to all of 1 2 { i.4 at once
   +/"_ [ 1 2 { i.4
3

   NB. mechanical translation to tacit form
   13 : '+/ x { y'
[: +/ {
ephemient
very helpful, thanks :)
cobbal