From: ······@gmail.com
Subject: Wikipedia article on APL has come of age!
Date: 
Message-ID: <df071312-7c46-444d-92d1-fc578f3a336d@q5g2000prf.googlegroups.com>
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/

☄

From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <f475cf84-4acc-444a-a206-57399f6dffa6@o40g2000prn.googlegroups.com>
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, ·······@gmail.com" <······@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/
>
> ☄
From: Stuart McGraw
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <d5b7a$48ab435b$401885f1$30233@DIALUPUSA.NET>
······@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.
From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <743e1386-7c6b-4537-a369-3fd6d7696d85@p10g2000prf.googlegroups.com>
On Aug 19, 3:09 pm, Stuart McGraw <·······@acedialup.com> wrote:
> ······@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/

☄
From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <3aa9ec5f-8b1b-432e-8c47-1778ad4b9d34@i20g2000prf.googlegroups.com>
On Aug 19, 3:09 pm, Stuart McGraw <·······@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/

☄
From: Bakul Shah
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <48AB5276.5090208@bitblocks.com>
······@gmail.com wrote:
> On Aug 19, 3:09 pm, Stuart McGraw <·······@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
From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <38733c3d-7113-475d-adbc-b470b71041f6@k36g2000pri.googlegroups.com>
On Aug 19, 4:08 pm, Bakul Shah <············@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/

☄
From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <384804a6-4dc8-4b0a-b105-cda4bed3bbc9@b38g2000prf.googlegroups.com>
On Aug 19, 4:26 pm, ·······@gmail.com" <······@gmail.com> wrote:
> On Aug 19, 4:08 pm, Bakul Shah <············@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/

☄
From: Bakul Shah
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <48ABB6F5.9020302@bitblocks.com>
······@gmail.com wrote:
> On Aug 19, 4:26 pm, ·······@gmail.com" <······@gmail.com> wrote:
>> On Aug 19, 4:08 pm, Bakul Shah <············@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.

First, an APL *operator* is much like a higher order function.
An APL primitive function is what you are calling an operator.
Primitive functions and user defined functions take 0, 1 or
2 operands and these are parsed strictly from right to left.
Thus
   f 1 + 2 == f (1 + 2)
   1 + f 2 == 1 + (f 2)
   1 2 + 3 4 == (1 2) + (3 4)
   1 - 2 + 3 4 == 1 - (2 + (3 4))
   1 ++ 2 == 1 + (+ 2)
and so on.  Yes, most primitive function symbols such as +
denote(usually) related unary and binary functions. And yes,
"1 2" is a vector and is treated as a single operand. Operators
like \ (scan) and / (insert -- what you may call foldl) do
have a higher binding strength. So "+/ 1 2 3" is parsed as
"(+/) (1 2 3)".

I should also say they are not just parsed but also *evaluated*
from left to right. So assignments affect the left side. So for
example
	(-r) + r ← 1 2 3
will give you 0 0 0. If you are really interested, try to find
a free implementation (such as A+) and play with it. Or j or Q.
The latter two don't need any special APL font. See the FAQ on
comp.lang.apl for a list of implementations, documentation etc.
From: Paul Donnelly
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <87zln88gqc.fsf@plap.localdomain>
·······@gmail.com" <······@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.
From: ······@gmail.com
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <be84b132-7069-4877-8862-327b7ab2d495@v39g2000pro.googlegroups.com>
On Aug 19, 9:15 pm, Paul Donnelly <·············@sbcglobal.net> wrote:
> ·······@gmail.com" <······@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/

☄
From: Ray Dillinger
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <48c411f2$0$17220$742ec2ed@news.sonic.net>
······@gmail.com wrote:

> What about optional parameters? How's APL deal with that?

AFAIK, APL has no functions with optional parameters. 

You really need at least as much syntax as lisp (which 
isn't much, but is at least enough to know where the 
list of arguments to a function ends) to have optional 
parameters.  Forth (for example) doesn't have that much 
syntax, and APL has but doesn't use syntax for that 
purpose.

                                Bear
From: Bob Hutchison
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <2008090911343716807-hutch@recursiveca>
On 2008-08-20 02:03:36 -0400, ·······@gmail.com" <······@gmail.com> said:
> 
> Thanks. I find the APL syntax rather elegant.

So do I, but I haven't used it since 1982.

> 
> It occured to me, that in APL, there's no function/operator that has 3
> or more argument?

That's right.

> 
> If that's true, then i suppose any need for 3 or more arguments are
> embeded as a 1-dimentional array aka vector?

You could. But, surprisingly, it doesn't happen too often.

> 
> What about optional parameters? How's APL deal with that?

Not allowed. Note that the symbol for monadic '-' (used to negate a 
number) is not the same symbol used for subtraction. The monadic '-' is 
raised to be more-or-less level with the top of the font. I don't think 
*any* operators were monadic and diadic. Multiplication, division, 
exponentiation etc all had their own symbols.

Another thing to think about is that in APL loops are avoided. In the 
'old days' they were incredibly slow while things like reduce '/' and 
scan '\' were relatively speaking blindingly fast. In order to 
facilitate this, dividing by zero could be defined to result in either 
a 0 or 1 which turned out to be very handy.

The lack of function precidence (which is how it is called in APL) lets 
you speak the line of code from left to right and make sense... try it. 
This is why Iverson chose this rule, or one of the main reasons at 
least (this is discussed in his book 'A Programming Language' from the 
1950's I think -- someone stole my copy).

BTW, APL can be very fast. The APL on the CDS 7700 (I think), which is 
quite a large scientifically oriented computer from the 1970's and 80's 
had an APL that was very often quite a lot faster than FORTRAN.

Cheers,
Bob

> 
>   Xah
> ∑ http://xahlee.org/
> 
> ☄
From: Mr. X
Subject: Re: Wikipedia article on APL has come of age!
Date: 
Message-ID: <zd3rk.3109$Is1.2162@newsfe04.iad>
APL is evaluated right to left.

Smalltalk is left to right.

Since most mainstream languages try to follow math conventions people often 
have trouble following both languages.


X