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.
why?
- giangiquario
- Posts: 46
- Joined: Thu Nov 26, 2009 8:55 am
- Location: Milano, Italia
Re: why?
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?
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.
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?
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:-(
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?
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.
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.