Trying this again - It
didn't seem to go through the first time...
I'm a newbie to APL2,
having played with APL\360 and APL/SV many years ago.
I was trying out some
examples with gnu-apl from an old Intro to APL2 manual that
I have from 1982.
They give two operators,
glue and AND as below.
⎕cr 'glue'
┏→━━━━━━━━━━━━━━━━━━━━━━━┓
↓z←(f glue l) r ┃
┃⍝From Intro to APL2, p72┃
┃z←l f r ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┛
⎕cr 'AND'
┏→━━━━━━━━━━━━━━━━━━━━━┓
↓z←(f AND g) r ┃
┃⍝From Intro to APL p72┃
┃z←(f r)(g r) ┃
┗━━━━━━━━━━━━━━━━━━━━━━┛
Using parenthesis,
gnu-apl gives this result which agrees with the book:
((*glue 2) AND*) 0
1 2
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃┏→━━━━┓
┏→━━━━━━━━━━━━━━━━━━━━━━━━┓┃
┃┃1 2 4┃ ┃1 2.718281828
7.389056099┃┃
┃┗━━━━━┛
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┗∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
But removing
parenthesis, gives gnu-apl gives a result that disagrees
with the manual in both of these 2 cases. In the manual, the
result is always the same as above.
(*glue 2 AND*) 0 1 2
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃
┃┃2
┏→━━━━━━━━━━━━━━━━━━━━━━━━┓┃ ┃2.718281828 15.15426224
1618.177992┃┃
┃┃ ┃1 2.718281828
7.389056099┃┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┃┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┃
┃┗∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┃
┗∊∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
*glue 2 AND* 0 1 2
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃
┃┃2
┏→━━━━━━━━━━━━━━━━━━━━━━━━┓┃ ┃2.718281828 15.15426224
1618.177992┃┃
┃┃ ┃1 2.718281828
7.389056099┃┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┃┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┃
┃┗∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┃
┗∊∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
It seems that the array
2 is binding as a left operand to AND rather than as a right
operand to glue.
When I force it with
these parenthesis, it works as expected.
(*glue 2) AND*
0 1 2
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃┏→━━━━┓
┏→━━━━━━━━━━━━━━━━━━━━━━━━┓┃
┃┃1 2 4┃ ┃1
2.718281828 7.389056099┃┃
┃┗━━━━━┛
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛┃
┗∊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
If I read the (later
1994 ) APL2 LRM, my understanding is the right operand
binding has higher precedence than left operand.
Is there something
different in GNU APL? Or is my understanding wrong (which
would also mean that something changed in IBM APL2 since
1982)
Clarification would be
appreciated.