Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm

On 3/12/2012 20:00, Albert van der Horst wrote:

In article4f5df4b3$0$1375$4fafb...@reader1.news.tin.it,
Kiuhnmkiuhnm03.4t.yahoo.it  wrote:

On 3/12/2012 12:27, Albert van der Horst wrote:

Interestingly in mathematics associative means that it doesn't matter
whether you use (a.b).c or a.(b.c).
Using xxx-associativity to indicate that it *does* matter is
a bit perverse, but the Perl people are not to blame if they use
a term in their usual sense.


You may see it this way:
Def1. An operator +:SxS-S is left-associative iff
   a+b+c = (a+b)+c for all a,b,c in S.
Def2. An operator +:SxS-S is right-associative iff
   a+b+c = a+(b+c) for all a,b,c in S.
Def3. An operator +:SxS-S is associative iff it is both left and
right-associative.


I know, but what the mathematicians do make so much more sense:
(a+b)+c = a+(b+c)definition of associative.
Henceforth we may leave out the brackets.


That's Def3. I don't see your point.


Don't leave out the brackets if the operators if the operators is
not associative.


(1 - 1) - 1 != 1 - (1 - 1)
and yet we can leave out the parentheses.


P.S. There is no need for the operators to be SxS-S.
For example a b c may be m by n, n by l, l by k matrices respectively.


Ops, you're right.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm

On 3/12/2012 20:00, Albert van der Horst wrote:

In article4f5df4b3$0$1375$4fafb...@reader1.news.tin.it,
Kiuhnmkiuhnm03.4t.yahoo.it  wrote:

On 3/12/2012 12:27, Albert van der Horst wrote:

Interestingly in mathematics associative means that it doesn't matter
whether you use (a.b).c or a.(b.c).
Using xxx-associativity to indicate that it *does* matter is
a bit perverse, but the Perl people are not to blame if they use
a term in their usual sense.


You may see it this way:
Def1. An operator +:SxS-S is left-associative iff
   a+b+c = (a+b)+c for all a,b,c in S.
Def2. An operator +:SxS-S is right-associative iff
   a+b+c = a+(b+c) for all a,b,c in S.
Def3. An operator +:SxS-S is associative iff it is both left and
right-associative.


I know, but what the mathematicians do make so much more sense:
(a+b)+c = a+(b+c)definition of associative.
Henceforth we may leave out the brackets.


That's Def3. I don't see your point.


Don't leave out the brackets if the operators if the operators is
not associative.


(1 - 1) - 1 != 1 - (1 - 1)
and yet we can leave out the parentheses.


P.S. There is no need for the operators to be SxS-S.
For example a b c may be m by n, n by l, l by k matrices respectively.


Ops, you're right.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm

On 3/12/2012 20:00, Albert van der Horst wrote:
[...]

Sorry for triple posting. I hadn't noticed the follow up and I was 
blaming my newsserver.

BTW, Python is the next language (right after Perl) I'm going to learn.
Then I'll probably have a look at Ruby...

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Albert van der Horst
In article 0078bbfb-5dfc-48fc-af1a-69de3cf15...@b1g2000yqb.googlegroups.com,
Xah Lee  xah...@gmail.com wrote:
New Science Discovery: Perl Idiots Remain Idiots After A Decade!

A excerpt from the new book =E3=80=88Modern Perl=E3=80=89, just published, =
chapter 4
on =E2=80=9COperators=E2=80=9D. Quote:

=C2=ABThe associativity of an operator governs whether it evaluates from
left to right or right to left. Addition is left associative, such
that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
** 4 first, then raises 2 to the 81st power. =C2=BB

LOL. Looks like the perl folks haven't changed. Fundamentals of
serious math got botched so badly.

You're confused.

Associativity of operators is defined in mathematics.
(The same concept may be used in programming).
left-associativity and right-associativity are computer languages
concept and their definitions are not from mathematics.

Interestingly in mathematics associative means that it doesn't matter
whether you use (a.b).c or a.(b.c).
Using xxx-associativity to indicate that it *does* matter is
a bit perverse, but the Perl people are not to blame if they use
a term in their usual sense.

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Kiuhnm

On 3/12/2012 12:27, Albert van der Horst wrote:

Interestingly in mathematics associative means that it doesn't matter
whether you use (a.b).c or a.(b.c).
Using xxx-associativity to indicate that it *does* matter is
a bit perverse, but the Perl people are not to blame if they use
a term in their usual sense.


You may see it this way:
Def1. An operator +:SxS-S is left-associative iff
  a+b+c = (a+b)+c for all a,b,c in S.
Def2. An operator +:SxS-S is right-associative iff
  a+b+c = a+(b+c) for all a,b,c in S.
Def3. An operator +:SxS-S is associative iff it is both left and 
right-associative.


Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Albert van der Horst
In article 4f5df4b3$0$1375$4fafb...@reader1.news.tin.it,
Kiuhnm  kiuhnm03.4t.yahoo.it wrote:
On 3/12/2012 12:27, Albert van der Horst wrote:
 Interestingly in mathematics associative means that it doesn't matter
 whether you use (a.b).c or a.(b.c).
 Using xxx-associativity to indicate that it *does* matter is
 a bit perverse, but the Perl people are not to blame if they use
 a term in their usual sense.

You may see it this way:
Def1. An operator +:SxS-S is left-associative iff
   a+b+c = (a+b)+c for all a,b,c in S.
Def2. An operator +:SxS-S is right-associative iff
   a+b+c = a+(b+c) for all a,b,c in S.
Def3. An operator +:SxS-S is associative iff it is both left and
right-associative.

I know, but what the mathematicians do make so much more sense:
(a+b)+c = a+(b+c)definition of associative.
Henceforth we may leave out the brackets.

Don't leave out the brackets if the operators if the operators is
not associative.

P.S. There is no need for the operators to be SxS-S.
For example a b c may be m by n, n by l, l by k matrices respectively.


Kiuhnm

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Kiuhnm

On 3/12/2012 20:00, Albert van der Horst wrote:

In article4f5df4b3$0$1375$4fafb...@reader1.news.tin.it,
Kiuhnmkiuhnm03.4t.yahoo.it  wrote:

On 3/12/2012 12:27, Albert van der Horst wrote:

Interestingly in mathematics associative means that it doesn't matter
whether you use (a.b).c or a.(b.c).
Using xxx-associativity to indicate that it *does* matter is
a bit perverse, but the Perl people are not to blame if they use
a term in their usual sense.


You may see it this way:
Def1. An operator +:SxS-S is left-associative iff
   a+b+c = (a+b)+c for all a,b,c in S.
Def2. An operator +:SxS-S is right-associative iff
   a+b+c = a+(b+c) for all a,b,c in S.
Def3. An operator +:SxS-S is associative iff it is both left and
right-associative.


I know, but what the mathematicians do make so much more sense:
(a+b)+c = a+(b+c)definition of associative.
Henceforth we may leave out the brackets.


That's Def3. I don't see your point.


Don't leave out the brackets if the operators if the operators is
not associative.


(1 - 1) - 1 != 1 - (1 - 1)
and yet we can leave out the parentheses.


P.S. There is no need for the operators to be SxS-S.
For example a b c may be m by n, n by l, l by k matrices respectively.


Ops, you're right.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-02 Thread Xah Lee
On Mar 1, 3:00 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote:
 They did not make up the terminology, if that is what you are saying.
 The concepts of left and right associativity are well-known and accepted
 in TCS (Theoretical CS).


 Aho, Sethi and Ullman explain it this way in Compilers: Principles,
 Techniques and Tools:
 We say that the operator + associates to the left because an operand
 with plus signs on both sides of it is taken by the operator to its
 left. [...]
 And they also show parse trees similar to the ones I wrote above.

how do they explain when 2 operators are adjacent e.g. 「3 △ 6 ▲ 5 」?

do you happen to know some site that shows the relevant page i can
have a look?

thanks.

 Xah

On Mar 1, 3:00 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote:
 On 3/1/2012 1:02, Xah Lee wrote:

  i missed a point in my original post. That is, when the same operator
  are adjacent. e.g. 「3 ▲ 6 ▲ 5」.

  This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
  Thanks.

  though, i disagree the way they expressed it, or any sense this is
  different from math.

 They did not make up the terminology, if that is what you are saying.
 The concepts of left and right associativity are well-known and accepted
 in TCS (Theoretical CS).

 If you change the terminology, no one will understand you unless you
 provide your definitions every time (and then they may not accept them).

 Another way of saying that an operator is left-associative is that its
 parse tree is a left-tree, i.e. a complete tree where each right child
 is a leaf.
 For instance, (use a monospaced font)
    1 + 2 + 3 + 4
 gives you this left-tree:
        +
      +   4
    +   3
   1 2
 while 1**2**3**4
 gives you this right-tree:
    **
 1    **
     2    **
         3  4

 Aho, Sethi and Ullman explain it this way in Compilers: Principles,
 Techniques and Tools:
 We say that the operator + associates to the left because an operand
 with plus signs on both sides of it is taken by the operator to its
 left. [...]
 And they also show parse trees similar to the ones I wrote above.

 Kiuhnm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-02 Thread Kiuhnm

On 3/2/2012 14:12, Xah Lee wrote:

On Mar 1, 3:00 am, Kiuhnmkiuhnm03.4t.yahoo.it  wrote:

They did not make up the terminology, if that is what you are saying.
The concepts of left and right associativity are well-known and accepted
in TCS (Theoretical CS).




Aho, Sethi and Ullman explain it this way in Compilers: Principles,
Techniques and Tools:
We say that the operator + associates to the left because an operand
with plus signs on both sides of it is taken by the operator to its
left. [...]
And they also show parse trees similar to the ones I wrote above.


how do they explain when 2 operators are adjacent e.g. 「3 △ 6 ▲ 5 」?


The same way you do, I guess. An operand that has operators on both 
sides is operand of the operator of higher precedence.

For instance, in
  3 * 4 + 6
4 is operand of * but not of +.
Indeed, the operands of + are 3*4 and 6.


do you happen to know some site that shows the relevant page i can
have a look?


Nope, sorry.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-01 Thread Kiuhnm

On 3/1/2012 1:02, Xah Lee wrote:

i missed a point in my original post. That is, when the same operator
are adjacent. e.g. 「3 ▲ 6 ▲ 5」.

This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
Thanks.

though, i disagree the way they expressed it, or any sense this is
different from math.


They did not make up the terminology, if that is what you are saying. 
The concepts of left and right associativity are well-known and accepted 
in TCS (Theoretical CS).


If you change the terminology, no one will understand you unless you 
provide your definitions every time (and then they may not accept them).


Another way of saying that an operator is left-associative is that its 
parse tree is a left-tree, i.e. a complete tree where each right child 
is a leaf.

For instance, (use a monospaced font)
  1 + 2 + 3 + 4
gives you this left-tree:
  +
+   4
  +   3
 1 2
while 1**2**3**4
gives you this right-tree:
  **
1**
   2**
   3  4

Aho, Sethi and Ullman explain it this way in Compilers: Principles, 
Techniques and Tools:
We say that the operator + associates to the left because an operand 
with plus signs on both sides of it is taken by the operator to its 
left. [...]

And they also show parse trees similar to the ones I wrote above.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-01 Thread Westley Martínez
First of all:

http://www.youtube.com/watch?v=z5jKMEB4hHE

On Wed, Feb 29, 2012 at 12:09:16AM -0800, Xah Lee wrote:
 Now, let me tell you what operator precedence is. First of all, let's
 limit ourselfs to discuss operators that are so-called binary
 operators, which, in our context, basically means single symbol
 operator that takes it's left and right side as operands. Now, each
 symbol have a “precedence”, or in other words, the set of operators
 has a order. (one easy way to think of this is that, suppose you have
 n symbols, then you give each a number, from 1 to n, as their order)
 So, when 2 symbols are placed side by side such as 「3 △ 6 ▲ 5」, the
 symbol with higher precedence wins. Another easy way to think of this
 is that each operator has a stickiness level. The higher its level, it
 more sticky it is.

You're absolutely correct.

 the problem with the perl explanations is that it's one misleading
 confusion ball. It isn't about “left/right associativity”. It isn't
 about “evaluates from left to right or right to left”. Worse, the word
 “associativity” is a math term that describe a property of algebra
 that has nothing to do with operator precedence, yet is easily
 confused with because it is a property about order of evaluation. (for
 example, the addition function is associative, meaning: 「(3+6)+5 =
 3+(6+5)」.)

You're not getting it.

Math is a language.  Perl is a language.  They have different rules for
grammar.  In Perl, C, Python, Java, and pretty much all procedural-based
languages, operations are evaluated in two steps: the precedence /and/
the associativity.  Each level of precedence has its own associativity,
either left-to-right or right-to-left.  You can see this in table 2-1 in
The C Programming Language.  Whatever math does or what you think math
does has nothing to do with the way Perl evaluates expressions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-01 Thread Chiron
On Wed, 29 Feb 2012 00:09:16 -0800, Xah Lee wrote:

Xah, you won't grow even an inch taller by cutting others down.

-- 
I joined scientology at a garage sale!!
-- 
http://mail.python.org/mailman/listinfo/python-list


New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Xah Lee
New Science Discovery: Perl Idiots Remain Idiots After A Decade!

A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
on “Operators”. Quote:

«The associativity of an operator governs whether it evaluates from
left to right or right to left. Addition is left associative, such
that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
** 4 first, then raises 2 to the 81st power. »

LOL. Looks like the perl folks haven't changed. Fundamentals of
serious math got botched so badly.

Let me explain the idiocy.

It says “The associativity of an operator governs whether it evaluates
from left to right or right to left.”. Ok, so let's say we have 2
operators: a white triangle △ and a black triangle ▲. Now, by the
perl's teaching above, let's suppose the white triangle is “right
associative” and the black triangle is “left associative”. Now, look
at this:

3 △ 6 ▲ 5

seems like the white and black triangles are going to draw a pistol
and fight for the chick 6 there. LOL.

Now, let me tell you what operator precedence is. First of all, let's
limit ourselfs to discuss operators that are so-called binary
operators, which, in our context, basically means single symbol
operator that takes it's left and right side as operands. Now, each
symbol have a “precedence”, or in other words, the set of operators
has a order. (one easy way to think of this is that, suppose you have
n symbols, then you give each a number, from 1 to n, as their order)
So, when 2 symbols are placed side by side such as 「3 △ 6 ▲ 5」, the
symbol with higher precedence wins. Another easy way to think of this
is that each operator has a stickiness level. The higher its level, it
more sticky it is.

the problem with the perl explanations is that it's one misleading
confusion ball. It isn't about “left/right associativity”. It isn't
about “evaluates from left to right or right to left”. Worse, the word
“associativity” is a math term that describe a property of algebra
that has nothing to do with operator precedence, yet is easily
confused with because it is a property about order of evaluation. (for
example, the addition function is associative, meaning: 「(3+6)+5 =
3+(6+5)」.)

compare it with this:

〈Perl & Python: Complex Numbers〉
http://xahlee.org/perl-python/complex_numbers.html

and for a good understanding of functions and operators, see:

〈What's Function, What's Operator?〉
http://xahlee.org/math/function_and_operators.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Chiron
On Wed, 29 Feb 2012 00:09:16 -0800, Xah Lee wrote:

Personally, I think this whole issue of precedence in a programming 
language is over-rated.  It seems to me that grouping of any non-trivial 
set of calculations should be done so as to remove any possible confusion 
as to intent.  It is one more obstacle to accidental errors in logic, 
where you intend one thing, possibly overlook precedence, and get a 
strange result.

Sure, mathematically it *should* go a particular way, and any programming 
language *should* follow that.  Still... they don't, and since they don't 
it makes more sense to be really obvious what you meant to do.

As someone pointed out, a programming language is for humans; computers 
don't need them.  That being the case, it makes sense to keep things as 
clear as possible.

-- 
It's OKAY -- I'm an INTELLECTUAL, too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Kiuhnm

On 2/29/2012 9:09, Xah Lee wrote:

New Science Discovery: Perl Idiots Remain Idiots After A Decade!

A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
on “Operators”. Quote:

«The associativity of an operator governs whether it evaluates from
left to right or right to left. Addition is left associative, such
that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
** 4 first, then raises 2 to the 81st power. »

LOL. Looks like the perl folks haven't changed. Fundamentals of
serious math got botched so badly.

Let me explain the idiocy.

It says “The associativity of an operator governs whether it evaluates
from left to right or right to left.”. Ok, so let's say we have 2
operators: a white triangle △ and a black triangle ▲. Now, by the
perl's teaching above, let's suppose the white triangle is “right
associative” and the black triangle is “left associative”. Now, look
at this:

3 △ 6 ▲ 5

seems like the white and black triangles are going to draw a pistol
and fight for the chick 6 there. LOL.


Sorry, but you're wrong and they're right.
Associativity governs the order of evaluation of a group of operators 
*OF THE SAME PRECEDENCE*.

If you write
  2**3**4
only the fact the '**' is right associative will tell you that the order is
  2**(3**4)
and not
  (2**3)**4
I remind you that 2^(3^4) != (2^3)^4.

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Devin Jeanpierre
On Wed, Feb 29, 2012 at 6:43 AM, Chiron chiron...@gmail.com wrote:
 Personally, I think this whole issue of precedence in a programming
 language is over-rated.  It seems to me that grouping of any non-trivial
 set of calculations should be done so as to remove any possible confusion
 as to intent.

Some languages do this. e.g. all lisps.

-- Devin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Rainer Weikusat
Xah Lee xah...@gmail.com writes:
 A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
 on “Operators”. Quote:

 «The associativity of an operator governs whether it evaluates from
 left to right or right to left. Addition is left associative, such
 that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
 Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
 ** 4 first, then raises 2 to the 81st power. »

 LOL. Looks like the perl folks haven't changed. Fundamentals of
 serious math got botched so badly.

 Let me explain the idiocy.

 It says “The associativity of an operator governs whether it evaluates
 from left to right or right to left.”. Ok, so let's say we have 2
 operators: a white triangle △ and a black triangle ▲. Now, by the
 perl's teaching above, let's suppose the white triangle is “right
 associative” and the black triangle is “left associative”. Now, look
 at this:

 3 △ 6 ▲ 5

 seems like the white and black triangles are going to draw a pistol
 and fight for the chick 6 there. LOL.

As the perlop manpage would have told you,

Operator associativity defines what happens if a sequence of the same
operators is used one after another

Since this is not the case in your example, it doesn't seem to be
applicable here. Also, the Perl I'm aware doesn't have 'white
triangle' and 'black triangle' operators and it also doesn't have
operators of equal precedence and different associativity. It can't,
actually, since there would be no way to evaluate an expression like
the mock one you invented above. Lastly, that something happens to be 
in one way or another way in the completely arbitrary set of rules and
conventions commonly referred to as 'mathematics' (an essentially
outdated write-only programming language dating back to the times
when humans had to perform computations themselves) doesn't mean it is
of any relevance anywhere else just because of this, no matter how
dear it might be to lots of people.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Kiuhnm

On 2/29/2012 16:15, Rainer Weikusat wrote:

[...] 'mathematics' (an essentially
outdated write-only programming language dating back to the times
when humans had to perform computations themselves) [...]


Theoretical Computer Science is a branch of mathematics. Are you saying 
it is outdated?


Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread namekuseijin
On Feb 29, 5:09 am, Xah Lee xah...@gmail.com wrote:
 New Science Discovery: Perl Idiots Remain Idiots After A Decade!

 A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
 on “Operators”. Quote:

 «The associativity of an operator governs whether it evaluates from
 left to right or right to left. Addition is left associative, such
 that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
 Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
 ** 4 first, then raises 2 to the 81st power. »

 LOL. Looks like the perl folks haven't changed. Fundamentals of
 serious math got botched so badly.

 Let me explain the idiocy.

 It says “The associativity of an operator governs whether it evaluates
 from left to right or right to left.”. Ok, so let's say we have 2
 operators: a white triangle △ and a black triangle ▲. Now, by the
 perl's teaching above, let's suppose the white triangle is “right
 associative” and the black triangle is “left associative”. Now, look
 at this:

 3 △ 6 ▲ 5

 seems like the white and black triangles are going to draw a pistol
 and fight for the chick 6 there. LOL.

 Now, let me tell you what operator precedence is. First of all, let's
 limit ourselfs to discuss operators that are so-called binary
 operators, which, in our context, basically means single symbol
 operator that takes it's left and right side as operands. Now, each
 symbol have a “precedence”, or in other words, the set of operators
 has a order. (one easy way to think of this is that, suppose you have
 n symbols, then you give each a number, from 1 to n, as their order)
 So, when 2 symbols are placed side by side such as 「3 △ 6 ▲ 5」, the
 symbol with higher precedence wins. Another easy way to think of this
 is that each operator has a stickiness level. The higher its level, it
 more sticky it is.

 the problem with the perl explanations is that it's one misleading
 confusion ball. It isn't about “left/right associativity”. It isn't
 about “evaluates from left to right or right to left”. Worse, the word
 “associativity” is a math term that describe a property of algebra
 that has nothing to do with operator precedence, yet is easily
 confused with because it is a property about order of evaluation. (for
 example, the addition function is associative, meaning: 「(3+6)+5 =
 3+(6+5)」.)

 compare it with this:

 〈Perl & Python: Complex 
 Numbers〉http://xahlee.org/perl-python/complex_numbers.html

 and for a good understanding of functions and operators, see:

 〈What's Function, What's 
 Operator?〉http://xahlee.org/math/function_and_operators.html

associativity of operators mean little in the Lisp world obviously, so
why was this posted here?  Sorry, perl, python and emacs folks...

BTW, it's the same in javascript: it is so such that 2 + 3 + 4 is
54 and 2 + 3 + 4 is 234.  Blame weak typing and + overloading,
though it may be a blessing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Xah Lee
i missed a point in my original post. That is, when the same operator
are adjacent. e.g. 「3 ▲ 6 ▲ 5」.

This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
Thanks.

though, i disagree the way they expressed it, or any sense this is
different from math.

to clarify, amend my original post, here's what's needed for binary
operator precedence:

① the symbols are ordered. (e.g. given a unique integer)

② each symbol is has either one of left-side stickness or right-side
stickness spec. (needed when adjacent symbols are the same.)

About the lisp case mentioned by Tim, e.g.  in「(f a b c)」, whether it
means 「(f (f a b) c)」 or 「(f a (f b c))」 . It is not directly relevant
to the context of my original post, because it isn't about to
operators. It's about function argument eval order. Good point,
nevertheless.

the perl doc, is still misleading, terribly bad written. Becha ass!

 Xah

On Feb 29, 4:08 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote:
 On 2/29/2012 9:09, Xah Lee wrote:


  New Science Discovery: Perl Idiots Remain Idiots After A Decade!

  A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
  on “Operators”. Quote:

  «The associativity of an operator governs whether it evaluates from
  left to right or right to left. Addition is left associative, such
  that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
  Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
  ** 4 first, then raises 2 to the 81st power. »

  LOL. Looks like the perl folks haven't changed. Fundamentals of
  serious math got botched so badly.

  Let me explain the idiocy.

  It says “The associativity of an operator governs whether it evaluates
  from left to right or right to left.”. Ok, so let's say we have 2
  operators: a white triangle △ and a black triangle ▲. Now, by the
  perl's teaching above, let's suppose the white triangle is “right
  associative” and the black triangle is “left associative”. Now, look
  at this:

  3 △ 6 ▲ 5

  seems like the white and black triangles are going to draw a pistol
  and fight for the chick 6 there. LOL.

 Sorry, but you're wrong and they're right.
 Associativity governs the order of evaluation of a group of operators
 *OF THE SAME PRECEDENCE*.
 If you write
    2**3**4
 only the fact the '**' is right associative will tell you that the order is
    2**(3**4)
 and not
    (2**3)**4
 I remind you that 2^(3^4) != (2^3)^4.

 Kiuhnm
-- 
http://mail.python.org/mailman/listinfo/python-list