[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave's and Matlab's limitations

From: Sergei Steshenko
Subject: Re: Octave's and Matlab's limitations
Date: Thu, 22 Nov 2012 10:31:33 -0800 (PST)

----- Original Message -----
> From: Dimitri Maziuk <address@hidden>
> To: Sergei Steshenko <address@hidden>
> Cc: "address@hidden" <address@hidden>
> Sent: Thursday, November 22, 2012 8:10 PM
> Subject: Re: Octave's and Matlab's limitations
> 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).
> Dima

Me too, but one shouldn't be a dogmatic. For example, in 'map' and 'grep' '$_' 
is _quite_ in order. A typical Perl idiom is converting an array into hash 
whose keys are the array elements and whose values don't matter - the hash is 
intended to be used later for existence checks.

So, it's quite OK IMO to write

my %hash; map {$hash{$_} = ''} @array;

Or, if one wants to find elements with 'foo' substring, it's quite OK to write

grep(/foo/, @array)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]