aplgnu-apl

Reduce by two with named function


I'm using GNU APL. Also, I'm not really sure what the correct name for this is, but the basic idea is that I have a list of things and I want to do something with each pair. It's complex, so I've made a function for it. I notice that this works:

      2+/1 2 3 4 5
┌→──────┐
│3 5 7 9│
└───────┘

I can even use an anonymous lambda to do the same thing:

      2{⍺+⍵}/1 2 3 4 5
┌→──────┐
│3 5 7 9│
└───────┘

However, it doesn't seem to work if I give that function a name:

      ∇R←X FOO Y
         R←X+Y
      ∇

      2FOO/1 2 3 4 5
SYNTAX ERROR
μ-Z__pA_LO_REDUCE_X4_B[3]  μ-T←⊂(⊃μ-B3[μ-H;μ-a-μ-M;μ-L])μ-LO⊃μ-T
                           ^    ^

Spacing differently doesn't seem to have any particular effect. Also, I'm not really able to see the relationship between the error message I got and what I typed in, so any insight into what is going on there would be very helpful to me. Thanks!


Solution

  • It works with the current GNU APL (1.7, svn 1013).

          ∇r←x foo y
    [1] r←x + y
    [2] ∇
          2 foo / 1 2 3 4
    3 5 7