range as in MATLAB/octave

Discussion in 'Perl Misc' started by Caj Zell, Jun 20, 2004.

  1. Caj Zell

    Caj Zell Guest

    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
     
    Caj Zell, Jun 20, 2004
    #1
    1. Advertising

  2. Caj Zell

    Anno Siegel Guest

    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
     
    Anno Siegel, Jun 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    4,534
    Kim Hansen
    Oct 8, 2009
  2. Replies:
    46
    Views:
    1,000
    Antoon Pardon
    Jul 25, 2006
  3. siki
    Replies:
    0
    Views:
    1,005
  4. Luna Moon
    Replies:
    16
    Views:
    1,430
    Giovanni Gherdovich
    Aug 8, 2008
  5. invis

    from octave to python

    invis, Jul 14, 2012, in forum: Python
    Replies:
    1
    Views:
    219
    invis
    Jul 14, 2012
Loading...

Share This Page