Re: How to make a new operator.

2012-03-22 Thread Daniel Carrera
On 22 March 2012 04:59, Jonathan Lang wrote: > My understanding is if you want to count by threes, starting at 2 and ending > at 14, you should be able to write: > >   2, 5 ... 14 That certainly looks very intuitive, and it is similar to what I would write in an email. The only annoyance is that

Re: How to make a new operator.

2012-03-22 Thread Carl Mäsak
Jonathan Lang (>>), Daniel (>): >> So: >> >>    1, 3 ... 13 # same as 1,3,5,7,9,11,13 >>    1 ... 10 # same as 1,2,3,4,5,6,7,8,9,10 >>    1, 2, 4 ... 100 # same as 1,2,4,8,16,32,64 > > That last one doesn't work on Rakudo :-( And it never will. Note that 100 is not a power of 2, and that the goal

Re: How to make a new operator.

2012-03-22 Thread Daniel Carrera
On 22 March 2012 11:02, Carl Mäsak wrote: >>>    1, 2, 4 ... 100 # same as 1,2,4,8,16,32,64 >> >> That last one doesn't work on Rakudo :-( > > And it never will. Note that 100 is not a power of 2, and that the > goal needs to match exactly. This is because smartmatching is used, ... > If you're wo

Re: How to make a new operator.

2012-03-22 Thread Moritz Lenz
On 03/22/2012 11:51 AM, Daniel Carrera wrote: > On 22 March 2012 11:02, Carl Mäsak wrote: 1, 2, 4 ... 100 # same as 1,2,4,8,16,32,64 >>> >>> That last one doesn't work on Rakudo :-( >> >> And it never will. Note that 100 is not a power of 2, and that the >> goal needs to match exactly. T

Re: How to make a new operator.

2012-03-22 Thread Daniel Carrera
On 22 March 2012 12:06, Moritz Lenz wrote: > >> But that's a bit of a problem if I *don't* want a value higher than 100. > > Then exclude it: 2, 4, 8 ...^ * > 100 Ok... I looked up what you did. I see how it works. Thanks. Related questions: What types of sequences can Perl 6 recognize? --

Re: How to make a new operator.

2012-03-22 Thread Carl Mäsak
Daniel (>): > Related questions:  What types of sequences can Perl 6 recognize? As covered by Jonathan Lang earlier in this thread (though it was perhaps easy to miss), Perl 6 auto-detects arithmetic sequences (same additive difference each time) and geometric sequences (same multiplicative factor

Re: How to make a new operator.

2012-03-22 Thread Bruce Gray
On Mar 21, 2012, at 11:49 PM, Jonathan Lang wrote: What I want to know is whether there's a way to define a step function that's based in part or in whole on the current term's index. For example, how would I use infix:<...> to generate the perfect squares between 0 and 100? Namely, '0,

Re: How to make a new operator.

2012-03-22 Thread Jon Lang
On Thu, Mar 22, 2012 at 9:07 AM, Bruce Gray wrote: > On Mar 21, 2012, at 11:49 PM, Jonathan Lang wrote: > > What I want to know is whether there's a way to define a step function >> that's based in part or in whole on the current term's index. For example, >> how would I use infix:<...> to gene

Re: How to make a new operator.

2012-03-22 Thread Moritz Lenz
Am 22.03.2012 17:07, schrieb Bruce Gray: I have run into the same need for something like :index, while playing with RosettaCode tasks like "Continued_fraction". If you want the index, don't use series. It's easy enough to access the array elements yourself. You can do something like my @a :

N-dimensional arrays and compiler support

2012-03-22 Thread Daniel Carrera
Hey, I have a few slightly related questions: 1. The semicolon operator would allow Perl 6 to support N-dimensional arrays... How would one iterate over that type of array? my num @matrix[ 10 ; 10 ; 10 ]; I ask because a natural extension is to add arithmetic operators and you have the beginnin

Re: How to make a new operator.

2012-03-22 Thread Martin D Kealey
On Thu, 22 Mar 2012, Carl Mäsak wrote: > Jonathan Lang (>>), Daniel (>): > >>    1, 2, 4 ... 100 # same as 1,2,4,8,16,32,64 > > > > That last one doesn't work on Rakudo :-( > > And it never will. Note that 100 is not a power of 2, and that the goal > needs to match exactly. This is because smartmat

Re: N-dimensional arrays and compiler support

2012-03-22 Thread Stefan O'Rear
On Thu, Mar 22, 2012 at 11:14:54PM +0100, Daniel Carrera wrote: > Hey, > > I have a few slightly related questions: > > 1. The semicolon operator would allow Perl 6 to support N-dimensional > arrays... How would one iterate over that type of array? > > my num @matrix[ 10 ; 10 ; 10 ]; > > I ask bec

Re: How to make a new operator.

2012-03-22 Thread Patrick R. Michaud
On Fri, Mar 23, 2012 at 03:03:09PM +1300, Martin D Kealey wrote: > On Thu, 22 Mar 2012, Carl Mäsak wrote: > > Jonathan Lang (>>), Daniel (>): > > >>    1, 2, 4 ... 100 # same as 1,2,4,8,16,32,64 > > > > > > That last one doesn't work on Rakudo :-( > > > > And it never will. Note that 100 is not a p

Re: How to make a new operator.

2012-03-22 Thread Damian Conway
Patrick correctly observed: > On Rakudo on my system, sqrt(2) indeed produces a Num, > but since floating point arithmetic doesn't result in > sqrt(2) / 1 == 2 / sqrt(2), no geometric sequence is deduced > and the sequence fails with "unable to deduce sequence". Although, arguably, that might be

Re: How to make a new operator.

2012-03-22 Thread Moritz Lenz
On 03/23/2012 07:01 AM, Damian Conway wrote: > Patrick correctly observed: > >> On Rakudo on my system, sqrt(2) indeed produces a Num, >> but since floating point arithmetic doesn't result in >> sqrt(2) / 1 == 2 / sqrt(2), no geometric sequence is deduced >> and the sequence fails with "unable to

Re: How to make a new operator.

2012-03-22 Thread Moritz Lenz
On 03/23/2012 05:30 AM, Patrick R. Michaud wrote: > On Fri, Mar 23, 2012 at 03:03:09PM +1300, Martin D Kealey wrote: >> Question: do we support >> >> 1, 2i, -4 ... 256 > > I think this ought to work, but for some reason Rakudo on my system > hangs whenever I try it. The problem was that inf