why?
8 posts
• Page 1 of 1
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
- JohnS|Dyalog
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.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
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:-(
- askom
- Posts: 36
- Joined: Fri Apr 09, 2010 7:22 pm
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.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group