i was pondering the benefits pros and cons of a left to right
notation. common calculators go left to right - 1 + 2 * 3 is 9. is
the fact that common calculators operate this way due to "common
sense" or an innate intuitiveness?
so ordinary J:
q=. 2 3 5 7 9
1 + 2 * q
5 7 11 15 19
then a left to right J could be:
2 3 5 7 9 =. q
q * 2 + 1
5 7 11 15 19
=. q may be the most offputting here, but this is just how a common
calculator works -- the "M+" key.
ta, jack
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
> hi guys,
>
> i was pondering the benefits pros and cons of a left to right
> notation. common calculators go left to right - 1 + 2 * 3 is 9. is
> the fact that common calculators operate this way due to "common
> sense" or an innate intuitiveness?
>
> so ordinary J:
>
> q=. 2 3 5 7 9
>
> 1 + 2 * q
> 5 7 11 15 19
>
>
> then a left to right J could be:
>
> 2 3 5 7 9 =. q
>
> q * 2 + 1
> 5 7 11 15 19
>
>
> =. q may be the most offputting here, but this is just how a common
> calculator works -- the "M+" key.
>
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
this question comes up so often I've started a couple of Wiki pages
addressing it.
Take a look at http://www.jsoftware.com/jwiki/NYCJUG/notationFAQ for an
argument why right-to-left execution is more useful than the reverse. Hint:
it becomes an issue only when you start thinking about arrays as basic
objects and how you apply functions across them.
Also, I've started a page to address the fallacy of thinking that there is
such a thing as a "standard mathematical notation":
http://www.jsoftware.com/jwiki/NYCJUG/MathematicalNotation . John Randall
has had a lot to say about this at J meetings - he especially recommends a
book by Cajori to get an historical perspective on this - but I don't think
either of us have written up anything on these discussions.
>
> hi guys,
>
> i was pondering the benefits pros and cons of a left to right
> notation. common calculators go left to right - 1 + 2 * 3 is 9. is
> the fact that common calculators operate this way due to "common
> sense" or an innate intuitiveness?
>
> so ordinary J:
>
> q=. 2 3 5 7 9
>
> 1 + 2 * q
> 5 7 11 15 19
>
>
> then a left to right J could be:
>
> 2 3 5 7 9 =. q
>
> q * 2 + 1
> 5 7 11 15 19
>
>
> =. q may be the most offputting here, but this is just how a common
> calculator works -- the "M+" key.
>
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
> hi guys,
>
> i was pondering the benefits pros and cons of a left to right
> notation. common calculators go left to right - 1 + 2 * 3 is 9. is
> the fact that common calculators operate this way due to "common
> sense" or an innate intuitiveness?
>
> so ordinary J:
>
> q=. 2 3 5 7 9
>
> 1 + 2 * q
> 5 7 11 15 19
>
>
> then a left to right J could be:
>
> 2 3 5 7 9 =. q
>
> q * 2 + 1
> 5 7 11 15 19
>
>
> =. q may be the most offputting here, but this is just how a common
> calculator works -- the "M+" key.
>
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Fornustekkum II, 781 Hornafirði
Po Box 127,801 Selfoss ,
t-póst: gosinn@... gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
[snipped from above link]:
2) for a non-commutative function, such as minus, the result is much
more interesting evaluated right to left, e.g. -/1 2 3 4 5
becomes the alternating sum (((1 - 2) + 3) - 4) + 5; if evaluation
were as in conventional mathematics, this would be equivalent
to the less interesting 1 - (2 + 3 + 4 + 5).
how would you express the 'less interesting' case in J? in
left-to-right, i would express the interesting case as
1 2 3 4 5 /-`+
ta, jack
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
On Fri, Jun 27, 2008 at 3:58 PM, Jack Andrews <effbiae@...> wrote:
> i was pondering the benefits pros and cons of a left to right
> notation.
One of the benefits is that they go well with writing monadic verbs as
prefixes, not suffixes. APL notation, however revolutionary it was,
is still influenced by common maths notation, which is why monadic
functions are written on the left, and why the (-) and (%) expect
arguments the order they do now. Another benefit is that we line
expressions up to the left, so the important part of the expression is
in one file. This way, you can usually easily find where a certain
name is assigned to, because that statement often has the name on the
left margin.
> common calculators go left to right - 1 + 2 * 3 is 9. is
> the fact that common calculators operate this way due to "common
> sense" or an innate intuitiveness?
That's a completely irrelevant issue here. You are referring to old
calculators which had to have very little memory so they can evaluate
such an expression incrementally as you type them only if the syntax
is associative that way.
Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
I'm sure that, by "one file" below, Ambrus is using "file" in the chess
sense of "rank and file" but to avoid confusion with the other common uses
of "file", we might want to say "one column". Other than this tiny quibble,
what he says is spot on. I see now that I had mis-understood the original
question as the one I'm used to seeing but, since others have provided such
good answers, I'll refrain from further prolonging this discussioni.
>
> On Fri, Jun 27, 2008 at 3:58 PM, Jack Andrews <effbiae@...> wrote:
> > i was pondering the benefits pros and cons of a left to right
> > notation.
>
> One of the benefits is that they go well with writing monadic verbs as
> prefixes, not suffixes. APL notation, however revolutionary it was,
> is still influenced by common maths notation, which is why monadic
> functions are written on the left, and why the (-) and (%) expect
> arguments the order they do now. Another benefit is that we line
> expressions up to the left, so the important part of the expression is
> in one file. This way, you can usually easily find where a certain
> name is assigned to, because that statement often has the name on the
> left margin.
>
>
> > common calculators go left to right - 1 + 2 * 3 is 9. is
> > the fact that common calculators operate this way due to "common
> > sense" or an innate intuitiveness?
>
>
> That's a completely irrelevant issue here. You are referring to old
> calculators which had to have very little memory so they can evaluate
> such an expression incrementally as you type them only if the syntax
> is associative that way.
>
>
> Ambrus
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
To put his argument in more tangible terms, when you were
in secondary school, Jack, what did you do with "sin cos y"?
Didn't you _read_ it from left to right and _execute_ it
from right to left?
Ken observed the many conventions used in maths,
often in contradiction with one another, and _selected_ (not invented)
one that was fruitful and could be universal and he made it universal.
~ Gilles
---------- Original Message -----------
From: "Devon McCormick" <devonmcc@...>
To: "Chat forum" <chat@...>
Sent: Sat, 28 Jun 2008 10:23:24 -0400
Subject: Re: [Jchat] right to/of left -- what about left to right?
> I'm sure that, by "one file" below, Ambrus is using "file" in the chess
> sense of "rank and file" but to avoid confusion with the other
> common uses of "file", we might want to say "one column". Other
> than this tiny quibble, what he says is spot on. I see now that I
> had mis-understood the original question as the one I'm used to
> seeing but, since others have provided such good answers, I'll
> refrain from further prolonging this discussioni.
>
> On 6/28/08, Zsbán Ambrus <ambrus@...> wrote:
> >
> > On Fri, Jun 27, 2008 at 3:58 PM, Jack Andrews <effbiae@...> wrote:
> > > i was pondering the benefits pros and cons of a left to right
> > > notation.
> >
> > One of the benefits is that they go well with writing monadic verbs as
> > prefixes, not suffixes. APL notation, however revolutionary it was,
> > is still influenced by common maths notation, which is why monadic
> > functions are written on the left, and why the (-) and (%) expect
> > arguments the order they do now. Another benefit is that we line
> > expressions up to the left, so the important part of the expression is
> > in one file. This way, you can usually easily find where a certain
> > name is assigned to, because that statement often has the name on the
> > left margin.
> >
> >
> > > common calculators go left to right - 1 + 2 * 3 is 9. is
> > > the fact that common calculators operate this way due to "common
> > > sense" or an innate intuitiveness?
> >
> >
> > That's a completely irrelevant issue here. You are referring to old
> > calculators which had to have very little memory so they can evaluate
> > such an expression incrementally as you type them only if the syntax
> > is associative that way.
> >
> >
> > Ambrus
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm > >
>
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
------- End of Original Message -------
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
Hi ... you know, just in case Echelon is listening. I'll leave your name
out;
Note that, where J does trig one way:
1 o. x
a common calculator does it the other way:
x sin
Jack Andrews wrote:
> hi guys,
>
> i was pondering the benefits pros and cons of a left to right
> notation. common calculators go left to right - 1 + 2 * 3 is 9. is
> the fact that common calculators operate this way due to "common
> sense" or an innate intuitiveness?
>
> so ordinary J:
>
> q=. 2 3 5 7 9
>
> 1 + 2 * q
> 5 7 11 15 19
>
>
> then a left to right J could be:
>
> 2 3 5 7 9 =. q
>
> q * 2 + 1
> 5 7 11 15 19
>
>
> =. q may be the most offputting here, but this is just how a common
> calculator works -- the "M+" key.
>
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
>
--
------------------------------------------------------------------------
|\/| Randy A MacDonald | APL: If you can say it, it's done.. (ram)
|/\| ramacd <at> nbnet.nb.ca |
|\ | | The only real problem with APL is that
BSc(Math) UNBF'83 | it is "still ahead of its time."
Sapere Aude | - Morten Kromberg
Natural Born APL'er |
-----------------------------------------------------(INTP)----{ gnat }-
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
earlier in the thread, the example of -/1 2 3 4 5 was given as a
demo of APL's evaluation order. 2 choices were identified - the APL
way:
(((1 - 2) + 3) - 4) + 5
and the common calculator way:
1 - (2 + 3 + 4 + 5)
in left to right, i would express these choices as:
1 2 3 4 5 /-`+
and
1 2 3 4 5 /-
but in j,
-/1 2 3 4 5
and
({.-+/@}.)1 2 3 4 5 NB. thanks, raul
doesn't this demonstrate that left to right has an advantage in
brevity (at least in this example)?
ta, jack
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
> earlier in the thread, the example of -/1 2 3 4 5 was given as a
> demo of APL's evaluation order. 2 choices were identified - the APL
> way:
> (((1 - 2) + 3) - 4) + 5
> and the common calculator way:
> 1 - (2 + 3 + 4 + 5)
>
> in left to right, i would express these choices as:
> 1 2 3 4 5 /-`+
> and
> 1 2 3 4 5 /-
>
> but in j,
> -/1 2 3 4 5
> and
> ({.-+/@}.)1 2 3 4 5 NB. thanks, raul
>
> doesn't this demonstrate that left to right has an advantage in
> brevity (at least in this example)?
>
>
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Fornustekkum II, 781 Hornafirði
Po Box 127,801 Selfoss ,
t-póst: gosinn@... gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
On 6/28/08, Jack Andrews <effbiae@gmail.com> wrote:
> how would you express the 'less interesting' case in J?
({.-+/@}.)1 2 3 4 5
Although this is correct in the case of -, I think the general solution to this
problem is -~/|.1 2 3 4 5
-/1 2 3 4 5
3
-~/|.1 2 3 4 5
_13
in the following sense:
f/1 2 3 4 5 NB. evaluates as:
1 f 2 f 3 f 4 f 5
(1 f(2 f(3 f(4 f 5)))) NB. default right to left order
f~/|.1 2 3 4 5 evaluates as:
f~/5 4 3 2 1 NB. default right to left order
5 f~ 4 f~ 3 f~ 2 f~ 1
(5 f~(4 f~(3 f~(2 f~ 1)))) NB. default right to left order
(4 f~(3 f~(2 f~ 1)))f 5
((3 f~(2 f~ 1))f 4)f 5
(((2 f~ 1)f 3)f 4)f 5
(((1 f 2)f 3)f 4)f 5 NB. left to right order
>
>
> Raul Miller-4 wrote:
> >
> > On 6/28/08, Jack Andrews <effbiae@...> wrote:
> >> how would you express the 'less interesting' case in J?
> >
> > ({.-+/@}.)1 2 3 4 5
> >
> >
>
> Although this is correct in the case of -, I think the general solution to
> this
> problem is -~/|.1 2 3 4 5
>
> -/1 2 3 4 5
> 3
> -~/|.1 2 3 4 5
> _13
>
> in the following sense:
>
> f/1 2 3 4 5 NB. evaluates as:
>
> 1 f 2 f 3 f 4 f 5
> (1 f(2 f(3 f(4 f 5)))) NB. default right to left order
>
>
> f~/|.1 2 3 4 5 evaluates as:
>
> f~/5 4 3 2 1 NB. default right to left order
> 5 f~ 4 f~ 3 f~ 2 f~ 1
> (5 f~(4 f~(3 f~(2 f~ 1)))) NB. default right to left order
> (4 f~(3 f~(2 f~ 1)))f 5
> ((3 f~(2 f~ 1))f 4)f 5
> (((2 f~ 1)f 3)f 4)f 5
> (((1 f 2)f 3)f 4)f 5 NB. left to right order
>
> --
> View this message in context:
> http://www.nabble.com/right-to-of-left----what-about-left-to-right--tp18155817s24193p18180713.html > Sent from the J Chat mailing list archive at Nabble.com.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm >
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Fornustekkum II, 781 Hornafirði
Po Box 127,801 Selfoss ,
t-póst: gosinn@... gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
Wasn't that the joke on the balance sheet of Bear Stearns?
On the right there was nothing left, on the left there was nothing right.
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: chat-bounces@... [mailto:chat-bounces@...] Namens
> Björn Helgason
> Verzonden: zaterdag 5 juli 2008 14:58
> Aan: Chat forum
> Onderwerp: Re: [Jchat] right to/of left -- what about left to right?
>
> Your brain is in two parts .left and right. The left part has nothing
> right
> in it and the right has nothing left in it.
>
> 2008/6/29 Viktor Cerovski <viktor.cerovski@...>:
>
> >
> >
> > Raul Miller-4 wrote:
> > >
> > > On 6/28/08, Jack Andrews <effbiae@...> wrote:
> > >> how would you express the 'less interesting' case in J?
> > >
> > > ({.-+/@}.)1 2 3 4 5
> > >
> > >
> >
> > Although this is correct in the case of -, I think the general solution
> to
> > this
> > problem is -~/|.1 2 3 4 5
> >
> > -/1 2 3 4 5
> > 3
> > -~/|.1 2 3 4 5
> > _13
> >
> > in the following sense:
> >
> > f/1 2 3 4 5 NB. evaluates as:
> >
> > 1 f 2 f 3 f 4 f 5
> > (1 f(2 f(3 f(4 f 5)))) NB. default right to left order
> >
> >
> > f~/|.1 2 3 4 5 evaluates as:
> >
> > f~/5 4 3 2 1 NB. default right to left order
> > 5 f~ 4 f~ 3 f~ 2 f~ 1
> > (5 f~(4 f~(3 f~(2 f~ 1)))) NB. default right to left order
> > (4 f~(3 f~(2 f~ 1)))f 5
> > ((3 f~(2 f~ 1))f 4)f 5
> > (((2 f~ 1)f 3)f 4)f 5
> > (((1 f 2)f 3)f 4)f 5 NB. left to right order
> >
> > --
> > View this message in context:
> > http://www.nabble.com/right-to-of-left----what-about-left-to-right-- > tp18155817s24193p18180713.html
> > Sent from the J Chat mailing list archive at Nabble.com.
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm > >
>
>
>
> --
> Björn Helgason, Verkfræðingur
> Fugl&Fiskur ehf,
> Fornustekkum II, 781 Hornafirði
> Po Box 127,801 Selfoss ,
> t-póst: gosinn@... > gsm: +3546985532
> Landslags og skrúðgarðagerð, gröfuþjónusta
> http://groups.google.com/group/J-Programming >
>
> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>
> góður kennari getur stigið á tær án þess að glansinn fari af skónum
> /|_ .-----------------------------------.
> ,' .\ / | Með léttri lund verður |
> ,--' _,' | Dagurinn í dag |
> / / | Enn betri en gærdagurinn |
> ( -. | `-----------------------------------'
> | ) | (\_ _/)
> (`-. '--.) (='.'=)
> `. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm