Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > range as in MATLAB/octave

Reply
Thread Tools

range as in MATLAB/octave

 
 
Caj Zell
Guest
Posts: n/a
 
      06-20-2004
Hello,

in MATLAB (or octave) you write 0:5:20 get a vector that's 0,5,10,15,20.

In perl I just did the following using the beginning, end and the interval.

@ratios=map $_*$interval,$lower..($upper/$interval);

Is there a nicer cleaner way using Perl?

Caj Zell
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      06-20-2004
Caj Zell <> wrote in comp.lang.perl.misc:
> Hello,
>
> in MATLAB (or octave) you write 0:5:20 get a vector that's 0,5,10,15,20.
>
> In perl I just did the following using the beginning, end and the interval.
>
> @ratios=map $_*$interval,$lower..($upper/$interval);
>
> Is there a nicer cleaner way using Perl?


As far as it has the semantics you want, that's one way of doing it.
You may want POSIX::floor to get the right behavior for negatives.

Anno
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I transform source range to destination range that is thesame as source? Lambda C++ 2 07-16-2008 05:18 PM
'ArgumentError: bad value for range' for range of Times David Bird Ruby 1 06-23-2008 12:12 PM
range() is not the best way to check range? Summercoolness@gmail.com Python 46 07-25-2006 08:10 PM
Scene range vs dynamic range Robert Feinman Digital Photography 2 07-04-2005 09:30 PM
Range does not take an Range object. Tomoyuki Kosimizu Ruby 3 11-27-2003 12:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57