| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Wikipedia article on APL has come of age! http://en.wikipedia.org/wiki/APL_(programming_language) See also: Conway's Game of Life in one line of APL By 2005 Michael Gertelman http://catpad.net/michael/apl/ btw, has anyone used apl mode in emacs? it doesn't seems to be bundled at least. Xah ∑ http://xahlee.org/ ☄ |
|
#2
| |||
| |||
| according to http://en.wikipedia.org/wiki/APL_(programming_language) quote: «As APL has many nonstandard primitives (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or operator precedence.» that cant be true, since function is a broad conception that includes any operators. But my question is about the statement that APL doesn't have operator precedence. As far as i know, in linear textual languages (as opposed to spread sheets, visual langs etc), unless it uses nested functional notation (e.g. Mathematica, lisp), i can't see how it can do without operator precedence? For example, in Wikipedia this code example for picking 6 random numbers from 1 to 40: ↑6?40 certainly there's operator precedence. e.g. (↑(6?40)) (↑(6?)40) (↑(6(?40))) (↑6)(?40) etc. So i think the Wikipedia statement “it does not have function or operator precedence” is wrong or needs qualifications. Xah ∑ http://xahlee.org/ ☄ On Aug 19, 1:51*pm, "xah...@gmail.com" <xah...@gmail.com> wrote: > Wikipedia article on APL has come of age!http://en.wikipedia.org/wiki/APL_(programming_language) > > See also: > > Conway's Game of Life in one line of APL > By 2005 Michael Gertelmanhttp://catpad.net/michael/apl/ > > btw, has anyone used apl mode in emacs? it doesn't seems to be bundled > at least. > > * Xah > ∑http://xahlee.org/ > > ☄ |
|
#3
| |||
| |||
| xahlee@gmail.com wrote: > according to > http://en.wikipedia.org/wiki/APL_(programming_language) > > quote: > «As APL has many nonstandard primitives (functions and operators, > indicated by a single symbol or a combination of a few symbols), it > does not have function or operator precedence.» > > that cant be true, since function is a broad conception that includes > any operators. > > But my question is about the statement that APL doesn't have operator > precedence. As far as i know, in linear textual languages (as opposed > to spread sheets, visual langs etc), unless it uses nested functional > notation (e.g. Mathematica, lisp), i can't see how it can do without > operator precedence? >[...] > So i think the Wikipedia statement “it does not have function or > operator precedence” is wrong or needs qualifications. It's been a while since I used APL but my recollection is that operator precedence is very simple: left-to-right (*). That is: a op1 b op2 c op3 d is parsed as: (a op1 (b op2 (c op3 d))) So I think the correct thing to say is that all APL operators have the same precedence and are right-associative. (*) I may be mis-remembering and operators are left- associative but I am pretty sure about the equal precedence part. |
|
#4
| |||
| |||
| On Aug 19, 3:09 pm, Stuart McGraw <smcg...@acedialup.com> wrote: > xah...@gmail.com wrote: > > according to > >http://en.wikipedia.org/wiki/APL_(programming_language) > > > quote: > > «As APL has many nonstandard primitives (functions and operators, > > indicated by a single symbol or a combination of a few symbols), it > > does not have function or operator precedence.» > > > that cant be true, since function is a broad conception that includes > > any operators. > > > But my question is about the statement that APL doesn't have operator > > precedence. As far as i know, in linear textual languages (as opposed > > to spread sheets, visual langs etc), unless it uses nested functional > > notation (e.g. Mathematica, lisp), i can't see how it can do without > > operator precedence? > >[...] > > So i think the Wikipedia statement “it does not have function or > > operator precedence” is wrong or needs qualifications. > > It's been a while since I used APL but my recollection > is that operator precedence is very simple: left-to-right (*). > That is: > > a op1 b op2 c op3 d > > is parsed as: > > (a op1 (b op2 (c op3 d))) > > So I think the correct thing to say is that all APL > operators have the same precedence and are right-associative. > > (*) I may be mis-remembering and operators are left- > associative but I am pretty sure about the equal precedence > part. Thanks. Though your explanation doesn't cover binary operators. e.g. in ↑6?40 clearly it is (↑(6?40)) and not (↑(6(?40))) Xah ∑ http://xahlee.org/ ☄ |
|
#5
| |||
| |||
| On Aug 19, 3:09 pm, Stuart McGraw <smcg...@acedialup.com> wrote: > > So i think the Wikipedia statement “it does not have function or > > operator precedence” is wrong or needs qualifications. > > It's been a while since I used APL but my recollection > is that operator precedence is very simple: left-to-right (*). > That is: > > a op1 b op2 c op3 d > > is parsed as: > > (a op1 (b op2 (c op3 d))) > > So I think the correct thing to say is that all APL > operators have the same precedence and are right-associative. > > (*) I may be mis-remembering and operators are left- > associative but I am pretty sure about the equal precedence > part. oops. My previous reply to you is a bit too fast. What i mean is, from your reply, does that mean any binary operator in APL is limited to just one occurance per line, and must be to the far right? Xah ∑ http://xahlee.org/ ☄ |
|
#6
| |||
| |||
| xahlee@gmail.com wrote: > On Aug 19, 3:09 pm, Stuart McGraw <smcg...@acedialup.com> wrote: > >>> So i think the Wikipedia statement “it does not have function or >>> operator precedence” is wrong or needs qualifications. >> It's been a while since I used APL but my recollection >> is that operator precedence is very simple: left-to-right (*). >> That is: >> >> a op1 b op2 c op3 d >> >> is parsed as: >> >> (a op1 (b op2 (c op3 d))) >> >> So I think the correct thing to say is that all APL >> operators have the same precedence and are right-associative. >> >> (*) I may be mis-remembering and operators are left- >> associative but I am pretty sure about the equal precedence >> part. > > > oops. My previous reply to you is a bit too fast. > > What i mean is, from your reply, does that mean any binary operator in > APL is limited to just one occurance per line, and must be to the far > right? > > Xah > ∑ http://xahlee.org/ > > ☄ They say it has no precedence rules because you parse from left to right. A monadic function grabs the result of *everything* to its right. A dyadic function grabs the result of everything to its right and the item on its left. Use parentheses when the left operand is to be computed from an expression. So for example you can do (2 × 3) + 4 × 5 and get 26. (× is the multiply function). I recommend you read Iverson's Turing Award lecture http://elliscave.com/APL_J/tool.pdf |
|
#7
| |||
| |||
| On Aug 19, 4:08 pm, Bakul Shah <bakul+use...@bitblocks.com> wrote: > ... > They say it has no precedence rules because you parse from left to > right. A monadic function grabs the result of *everything* to its > right. A dyadic function grabs the result of everything to its right > and the item on its left. Use parentheses when the left operand is > to be computed from an expression. So for example you can do > (2 × 3) + 4 × 5 > and get 26. (× is the multiply function). That still does not explain fully how binary operation works without precedence. For example (2 × 3) + 4 × 5 becomes 6 + 4 × 5 But now, is it 6 + (4 × 5) or (6 + 4) × 5 ? from your explanation, it seems when when binary operator appear in sequence, the right most has precedence?? but then, what happens when uninary and binary operator are combined, as in f 1 + 2 would that mean f (1 + 2) or (f 1) + 2 > I recommend you read Iverson's Turing Award lecture > http://elliscave.com/APL_J/tool.pdf Thanks. Xah ∑ http://xahlee.org/ ☄ |
|
#8
| |||
| |||
| On Aug 19, 4:26 pm, "xah...@gmail.com" <xah...@gmail.com> wrote: > On Aug 19, 4:08 pm, Bakul Shah <bakul+use...@bitblocks.com> wrote: > > > ... > > They say it has no precedence rules because you parse from left to > > right. A monadic function grabs the result of *everything* to its > > right. A dyadic function grabs the result of everything to its right > > and the item on its left. Use parentheses when the left operand is > > to be computed from an expression. So for example you can do > > (2 × 3) + 4 × 5 > > and get 26. (× is the multiply function). damn, post too past again. Ok, summarizing posts in thread, it seems to be this: in APL, there's uninary and binary operators. When uninary operator are sequenced, right most takes precedence. When binary are sequenced, the right most takes precedence. When both are mixed, Binary operator has precedence than uninary. Paren can be used to break the above precedence rule. That seems to summarize it without ambiguity. Though, it still has precedence, just a simple one though. Xah ∑ http://xahlee.org/ ☄ |
|
#9
| |||
| |||
| "xahlee@gmail.com" <xahlee@gmail.com> writes: > according to > http://en.wikipedia.org/wiki/APL_(programming_language) > > quote: > «As APL has many nonstandard primitives (functions and operators, > indicated by a single symbol or a combination of a few symbols), it > does not have function or operator precedence.» > > that cant be true, since function is a broad conception that includes > any operators. > > But my question is about the statement that APL doesn't have operator > precedence. As far as i know, in linear textual languages (as opposed > to spread sheets, visual langs etc), unless it uses nested functional > notation (e.g. Mathematica, lisp), i can't see how it can do without > operator precedence? > > For example, in Wikipedia this code example for picking 6 random > numbers from 1 to 40: > > ↑6?40 > > certainly there's operator precedence. e.g. > > (↑(6?40)) > (↑(6?)40) > (↑(6(?40))) > (↑6)(?40) > > etc. > > So i think the Wikipedia statement “it does not have function or > operator precedence” is wrong or needs qualifications. There are several other languages (that come to mind immediately) with no operator precedence rules. K and Q, descendents of APL, as well as Smalltalk (which doesn't have operators in the same way, but reads like it does). I believe the way APL, K, and Q do it is to group from right to left. 3*2+1 => 3*(2+1) => (3*(2+1)) => 9 1+2*3 => 1+(2*3) => (1+(2*3)) => 7 ↑6?40 => ↑(6?40) => (↑(6?40)) => 3 4 6 11 24 30 (possibly) Deal 6 from 40 then sort the result. ↑ is sort when used as a unary function, and selects the first n from m when used like n↑m. The two cases can be distinguished by examining the thing to the left of ↑, if it's nothing or an operator, the function is unary, if it's a value the function is binary. If there happens to be more than one value to the right of an operator, it will take them all, I think. Parentheses can be used for explicit grouping. A←5 4 3 2 ↓↑A Sort A then drop its first element => 3 4 5 2↑A Give me the first two elements of A => 5 4 Smalltalk's parsing rules make it come out roughly the opposite way. 3*2+1 => (3*2)+1 => ((3*2)+1) 1+2*3 => (1+2)*3 => ((1+2)*3) I've only dabbled in these, so I may be wrong. |
|
#10
| |||
| |||
| On Aug 19, 9:15 pm, Paul Donnelly <paul-donne...@sbcglobal.net> wrote: > "xah...@gmail.com" <xah...@gmail.com> writes: > > according to > >http://en.wikipedia.org/wiki/APL_(programming_language) > > > quote: > > «As APL has many nonstandard primitives (functions and operators, > > indicated by a single symbol or a combination of a few symbols), it > > does not have function or operator precedence.» > > > that cant be true, since function is a broad conception that includes > > any operators. > > > But my question is about the statement that APL doesn't have operator > > precedence. As far as i know, in linear textual languages (as opposed > > to spread sheets, visual langs etc), unless it uses nested functional > > notation (e.g. Mathematica, lisp), i can't see how it can do without > > operator precedence? > > > For example, in Wikipedia this code example for picking 6 random > > numbers from 1 to 40: > > > ↑6?40 > > > certainly there's operator precedence. e.g. > > > (↑(6?40)) > > (↑(6?)40) > > (↑(6(?40))) > > (↑6)(?40) > > > etc. > > > So i think the Wikipedia statement “it does not have function or > > operator precedence” is wrong or needs qualifications. > > There are several other languages (that come to mind immediately) with > no operator precedence rules. K and Q, descendents of APL, as well as > Smalltalk (which doesn't have operators in the same way, but reads > like it does). I believe the way APL, K, and Q do it is to group from > right to left. > > 3*2+1 => 3*(2+1) => (3*(2+1)) => 9 > 1+2*3 => 1+(2*3) => (1+(2*3)) => 7 > > ↑6?40 => ↑(6?40) => (↑(6?40)) => 3 4 6 11 24 30 (possibly) > > Deal 6 from 40 then sort the result. ↑ is sort when used as a unary > function, and selects the first n from m when used like n↑m. The two > cases can be distinguished by examining the thing to the left of ↑, if > it's nothing or an operator, the function is unary, if it's a value > the function is binary. If there happens to be more than one value to > the right of an operator, it will take them all, I think. Parentheses > can be used for explicit grouping. > > A←5 4 3 2 > > ↓↑A > Sort A then drop its first element => 3 4 5 > > 2↑A > Give me the first two elements of A => 5 4 > > Smalltalk's parsing rules make it come out roughly the opposite way. > > 3*2+1 => (3*2)+1 => ((3*2)+1) > 1+2*3 => (1+2)*3 => ((1+2)*3) > > I've only dabbled in these, so I may be wrong. Thanks. I find the APL syntax rather elegant. It occured to me, that in APL, there's no function/operator that has 3 or more argument? If that's true, then i suppose any need for 3 or more arguments are embeded as a 1-dimentional array aka vector? What about optional parameters? How's APL deal with that? Xah ∑ http://xahlee.org/ ☄ |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.