Front page | perl.perl6.language |
Postings from March 2012
Re: How to make a new operator.
Thread Previous
|
Thread Next
From:
Daniel Carrera
Date:
March 21, 2012 14:39
Subject:
Re: How to make a new operator.
Message ID:
CAEaabNg3hf=ZuTfo_9jj78DEY+OqpP_FghpXhPM2GiC+J6Swcw@mail.gmail.com
On 21 March 2012 22:09, Damian Conway <damian@conway.org> wrote:
>> Is it possible to create a new range operator ':' such that:
>
> Do you need to?
Hmm... maybe not...
>> a:b:c is a range from 'a' to 'b' by steps of 'c'.
>
> Perl 6 already has: $a,*+$c...* >=$b
>
> E.g. 2, 5 ...^ *>=15 ----> 2,5,8,11,14
That looks really scary. I'll try to figure out what it means later.
> Perl 6 already has ^$b
> Perl 6 already has $a..* or $a...*
> Perl 6 already has: ^Inf ----> 0,1,2,3,4,5,....
Ok... I think can use that.
I want to write a simple class for numerical computation. Mostly
because I don't like NumPy, PDL or Octave/Matlab. When I wrote my
email I was thinking of slices:
@matrix[2..5][3..7]
@matrix[2..5][*]
@matrix[5..*][^3]
I guess that's alright. It doesn't seem to be worth the effort in
adding new syntax.
I'm having trouble getting this to work with Rakudo Star (2012.02) though...
> my @a = \[1,2,3,4,5], \[6,7,8,9,0]
1 2 3 4 5 6 7 8 9 0
>
> @a[0]
1 2 3 4 5
>
> @a[0].WHAT
Capture()
>
> @a[0][2]
Any()
:-(
> Perl 6 already has: 0,$c...*
>
> e.g. 0,3...* ----> 0, 3, 6, 9, 12....
Interesting... but it doesn't seem to work in Rakudo Star (2012.02):
> @(2,5..10)
2 5 6 7 8 9 10
:-(
Cheers,
Daniel.
--
I'm not overweight, I'm undertall.
Thread Previous
|
Thread Next