[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave's and Matlab's limitations
From: |
Dimitri Maziuk |
Subject: |
Re: Octave's and Matlab's limitations |
Date: |
Thu, 22 Nov 2012 12:10:21 -0600 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
On 11/21/2012 6:45 PM, Sergei Steshenko wrote:
I like Perl, and I do not write it this way. The example you gave is unfair in
several respects:
Yes, and quite deliberately, too. ;) My point was that to someone who
hasn't touched math since Scientific Computing 201 and matlab -- never
(we did it in C), e.g. "A([1:2:97 98 99],[1:end-1]) = (B > C);" quoted
downthread looks no different from obfuscated perl.
I do spell things out and never use "$_" either (when I have to write perl).
...
3 print("The absolute value of", n, "is", -n)
Number? 1 The absolute value of 1 is 1
vs
('The absolute value of', 1, 'is', 1)
So, is it a bug or a feature or an outdated tutorial ?
Yes.
Apparently fixed it in 3.0 (I use OS python) and can be enabled in some
2.x versions by "import __future__" (that's the "outdated" part).
Basically, print is not a function in 2.x, it's a statement, so () after
"print" mean something else. In this context they're confusing (and
possibly ambiguous) -- that's the bug part:
- ("foo", "bar") defines a tuple (pair) of strings. Tuple is printed in
brackets to show you it's a tuple (that's the "feature" part),
- comma after print's argument means "don't print newline",
- brackets also used as you'd expect: to group expressions.
So
print("abs of %d is %d" % (n, -n)),
and
print("abs of", n, "is", -n),
mean two different things.
Like I said, python's not great. But whitespace forces people format
their code in a more readable shape and if you ever watched cpan try to
download and build perl 5.678 because you wanted GD graphs -- and on a
non-GNU platform where it fails at 'cc != gcc' -- you get to appreciate
"batteries included" standard library. If only they had manifest typing...
Dima
- Re: Octave's and Matlab's limitations, (continued)
- Re: Octave's and Matlab's limitations, c., 2012/11/21
- Re: Octave's and Matlab's limitations, Dimitri Maziuk, 2012/11/21
- Re: Octave's and Matlab's limitations, c., 2012/11/21
- Re: Octave's and Matlab's limitations, Jake, 2012/11/21
- Re: Octave's and Matlab's limitations, Salva Ardid, 2012/11/21
- Re: Octave's and Matlab's limitations, Kjetil brinchmann Halvorsen, 2012/11/21
- Re: Octave's and Matlab's limitations, Sergei Steshenko, 2012/11/21
- Re: Octave's and Matlab's limitations, Dimitri Maziuk, 2012/11/21
- Re: Octave's and Matlab's limitations, Sergei Steshenko, 2012/11/21
- Re: Octave's and Matlab's limitations, Sergei Steshenko, 2012/11/21
- Re: Octave's and Matlab's limitations,
Dimitri Maziuk <=
- Re: Octave's and Matlab's limitations, Sergei Steshenko, 2012/11/22
- Re: Octave's and Matlab's limitations, Francesco Potortì, 2012/11/22
- Re: Octave's and Matlab's limitations, c., 2012/11/22
- Re: Octave's and Matlab's limitations, Sergei Steshenko, 2012/11/22
- Re: Octave's and Matlab's limitations, c., 2012/11/22
- Re: Octave's and Matlab's limitations, Jordi Gutiérrez Hermoso, 2012/11/22
- Re: Octave's and Matlab's limitations, Francesco Potortì, 2012/11/22
- Re: Octave's and Matlab's limitations, Jordi Gutiérrez Hermoso, 2012/11/22
- Re: Octave's and Matlab's limitations, Jordi Gutiérrez Hermoso, 2012/11/22
- Re: Octave's and Matlab's limitations, Francesco Potortì, 2012/11/22