Hi Elias,
I assume by spec you mean ISO/IEC 13751.
They give the following syntax:
Z ← f ⍤y B (deriving monadically) and
Z ← A f ⍤y B (deriving dyadically).
They say that f ⍤y is a function which is then called with arguments B
and possibly A.
Thus Z is a value and not a function; the function is created internally.
The problem with ⍤ is its ambiguity regarding y.
y is expected to be a vector with 1, 2, or 3 elements.
Now look at:
+⍤1 2 3 4 5
AXIS ERROR
+⍤1 2 3 4 5
^^
The problem is that this could mean several things:
+⍤1 (2 3 4 5)
2 3 4 5
+⍤1 2 (3 4 5)
3 4 5
+⍤1 2 3 (4 5)
4 5
In your example,
* {'foo',⍵}⍤1 4 5⍴⍳10*
first *1 4 5⍴⍳10 i*s computed and then *{'foo',⍵}⍤y B *with an empty y
and B the result of *1 4 5⍴⍳10*.
The empty y then causes the axis error.
What you probably intended to do is:
* {'foo',⍵}⍤1 (4 5⍴⍳10)*
foo 1 2 3 4 5
foo 6 7 8 9 10
foo 1 2 3 4 5
foo 6 7 8 9 10
In GNU APL you can put the y in axis brackets to resolve the ambiguity.
I personally believe *⍤*[y] B is a clearer syntax than *⍤*y B.
* {'foo',⍵}⍤[1] 4 5⍴⍳10*
foo 1 2 3 4 5
foo 6 7 8 9 10
foo 1 2 3 4 5
foo 6 7 8 9 10
/// Jürgen
n 03/04/2014 05:28 PM, Elias Mårtenson wrote:
I was playing around with the Rank Operator, which is something that
isn't really documented in many places. I only saw references to it in
the spec, while neither APL2 nor Dyalog mentions it.
Now, there are a few things that behaves strangely, although it may be
correct.
First of all, the following works (]BOXING is 8):
*xx ← 4 5⍴⍳10*
* {'foo',⍵}⍤1 xx*
┌→─────────────┐
↓foo 1 2 3 4 5│
│foo 6 7 8 9 10│
│foo 1 2 3 4 5│
│foo 6 7 8 9 10│
└──────────────┘
But the following does not:
*{'foo',⍵}⍤1 4 5⍴⍳10*
RANK ERROR
λ1⍤1 4 5⍴⍳10
^ ^
*({'foo',⍵}⍤1) 4 5⍴⍳10*
RANK ERROR
(λ1⍤1)4 5⍴⍳10
^ ^
Also, the spec says it returns a function, but I can't assign it to a
variable:
*a ← {'foo',⍵}⍤1*
RANK ERROR
a←λ1⍤1
^ ^
I suppose the last one is expected, since *xy←+/* also does not work
(but should it?)
Is the behaviour correct, or is there a problem with the parsing?
Regards,
Elias