Page 1 of 1
why?
Posted: Mon May 17, 2010 11:44 pm
by askom
x←(1 2 3)(4 2 5)
1∘.,x
1 1 2 3 1 4 2 5
1∘.,[1.5]x
SYNTAX ERROR
1∘.,[1.5]x
∧
Regards,
Sasha.
Re: why?
Posted: Tue May 18, 2010 7:26 am
by giangiquario
Maybe the correct spelling is
Regards, Gianluigi
Re: why?
Posted: Tue May 18, 2010 8:04 am
by JohnS|Dyalog
Code: Select all
I think Gianluigi is right:
x←(1 2 3)(4 5 6)
1∘.,x
1 1 2 3 1 4 5 6
1∘.,[1.5]x
SYNTAX ERROR
1∘.,[1.5]x
∧
1∘.(,[1.5])x
1 1 1 4
1 2 1 5
1 3 1 6
)copy dfns ddft
u:\ws\dfns saved Sat May 15 11:54:54 2010
∘.,[1.5] ddft 1 ⍝ display derived function tree.
[
┌─┴─┐
. 1.5
┌─┴─┐
∘ ,
∘.(,[1.5]) ddft 1
.
┌─┴─┐
∘ ,[·1.5
Re: why?
Posted: Tue May 18, 2010 5:22 pm
by askom
Thanks Gianluigi and John. It's a pity that it is not a bug.
Not easy to explain to students and not pleasant to look at that code:-)
In APL2 it works like I posted.
Re: why?
Posted: Tue May 18, 2010 9:39 pm
by Phil Last
Binding strengths.
APL2 Dyalog
right-operand vector
bracket bracket
vector right-operand
left-operand left-operand
left-argument left-argument
right-argument right-argument
There are good arguments for either order and both create strange (yes, and ugly) seeming anomolies.
Re: why?
Posted: Tue May 18, 2010 10:44 pm
by askom
Good analysis. Thanks.
I vote for the short one:-) APL2.
/Sasha.
Re: why?
Posted: Tue May 18, 2010 11:07 pm
by askom
look at the expression again:
1∘.,[1.5]x
my way of explanation, right to left movement:
x is a variable, look to the left to see what to do
] may be index or axis specification, go more to the left
, may be ravel or concatenate, go more to the left
. may be inner product or outer product, go more to the left
∘. is the inner product, so "," is the right operand and [1.5] axis spec
1 is the left argument
I always tell to my students that the only use of parentheses is change the order
of execution.
1∘.(,[1.5])x
The above is not change the order of execution. I was wrong:-(
Re: why?
Posted: Wed May 19, 2010 1:58 pm
by Phil Last
I believe it was Jim Brown's view that APL2 rationalised the use of Parentheses such that "parentheses are for grouping. Period."
APL2's switching of the "strength" of Bracket and Vector binding was justified on the grounds that in nested vector:
vec0 vec1 vec2
if we want to index one or more of the sub vectors we would need brackets AND parentheses if vector binding were stronger than bracket:
vec0 vec1[x] vec2 ⍝ APL2
vec0(vec1[x])vec2 ⍝ Dyalog
The problem is that in order to save those unusual parentheses APL2 now requires all literal indexed vectors to be parenthesised:
5 4 6 3 7 2 8 1 9[x] ⍝ APL (ISO 8485)
(5 4 6 3 7 2 8 1 9)[x] ⍝ APL2
Swings and roundabouts.