Parrot 4.2.0 Ornithopter Released!

2012-03-21 Thread Jonathan Duke Leto
Technology, in common with many other activities, tends toward avoidance of risks by investors. Uncertainty is ruled out if possible. Capital investment follows this rule, since people generally prefer the predictable. Few recognize how destructive this can be, how it imposes severe limits on

How to make a new operator.

2012-03-21 Thread Daniel Carrera
Hello, Is it possible to create a new range operator ':' such that: a:b is the same as a..b (this is the easy part) a:b:c is a range from 'a' to 'b' by steps of 'c'. For example, 2:15:3 == 2,5,8,11,14 :b is the same as 0..b a: is the same as a..Inf ::c is the same as 0:Inf:c : is the same

Re: How to make a new operator.

2012-03-21 Thread Moritz Lenz
On 03/21/2012 09:07 PM, Daniel Carrera wrote: Hello, Is it possible to create a new range operator ':' such that: a:b is the same as a..b (this is the easy part) a:b:c is a range from 'a' to 'b' by steps of 'c'. For example, 2:15:3 == 2,5,8,11,14 That can be done by giving the new

Re: How to make a new operator.

2012-03-21 Thread Daniel Carrera
Hi Moritz a:b is the same as a..b  (this is the easy part) a:b:c is a range from 'a' to 'b' by steps of 'c'. For example, 2:15:3 == 2,5,8,11,14 That can be done by giving the new infix:: operator list associativity (niecza already supports this) Can you explain or give me a link that

Re: How to make a new operator.

2012-03-21 Thread Damian Conway
Is it possible to create a new range operator ':' such that: Do you need to? 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 :b is the same as 0..b Perl 6 already has ^$b e,g, ^100 0..99 a: is the same

Re: How to make a new operator.

2012-03-21 Thread Carl Mäsak
Daniel (), Damian (): : is the same as 0..Inf Perl 6 already has: ^Inf 0,1,2,3,4,5, Hah, Damian made an off-by-one error! Oh wait... // Carl

Re: How to make a new operator.

2012-03-21 Thread Carl Mäsak
Damian (), Daniel (): 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 :-( Keep in mind that infix:.. will listify to the kind of one-step-at-a-time range that was produced

Re: How to make a new operator.

2012-03-21 Thread Damian Conway
Interesting... but it doesn't seem to work in Rakudo Star (2012.02): @(2,5..10) You need three dots, not two. Damian

Re: How to make a new operator.

2012-03-21 Thread Daniel Carrera
On 21 March 2012 22:50, Carl Mäsak cma...@gmail.com wrote: It would also produce an infinite list, because by the rules you need the RHS of infix:... to match exactly, and 10 is not in the infinite list 2, 5, 8, 11, 14... Which is why you'd need to write something like * = 10. Ok, so

Re: How to make a new operator.

2012-03-21 Thread Damian Conway
Ok, so infix:... isn't what I wish for either... Can you help me understand Damian's example? Breaking down that example: $a, # Start at $a *+$c # Generate next number via: sub($prev_num} { $prev_num + $c } ... # Repeat until... * =$b # ...this sub matches:

Re: How to make a new operator.

2012-03-21 Thread Daniel Carrera
On 22 March 2012 00:08, Brandon Allbery allber...@gmail.com wrote: * + $c --- the next value is the current value plus $c.  (* means Whatever, and generally refers to the current value of something.  In this case, we're specifying how to make a new value given a current value.  You can think

Re: How to make a new operator.

2012-03-21 Thread Solomon Foster
On Wed, Mar 21, 2012 at 7:52 PM, Daniel Carrera dcarr...@gmail.com wrote: * = $b --- this determines where the sequence ends:  when the current value is greater or equal to $b. So...  after the ... you have an anonymous function that has to return 'True' for the sequence to end? Seems

Re: How to make a new operator.

2012-03-21 Thread Daniel Carrera
On 22 March 2012 01:13, Solomon Foster colo...@gmail.com wrote: It actually smartmatches whatever is on the right hand side against the sequence, and stops when the smartmatch returns True.  It just happens that you smartmatch an anonymous function, it executes the function and returns its

Re: How to make a new operator.

2012-03-21 Thread Jonathan Lang
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 is, the list-building operator looks at the previous two or three terms preceding it to determine where to start and what step function to use, and then looks

Re: How to make a new operator.

2012-03-21 Thread Jonathan Lang
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,1,4,9,16,25,36,49,64,81,100'. For example, is Perl 6 set