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
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
On 22 March 2012 01:13, Solomon Foster 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 result.
I see.
On Wed, Mar 21, 2012 at 7:52 PM, Daniel Carrera 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 strange, but it
On 22 March 2012 00:08, Brandon Allbery 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 of it as a w
> 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:
On 21 March 2012 22:50, Carl Mäsak 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 infix:<...> isn't
> Interesting... but it doesn't seem to work in Rakudo Star (2012.02):
>
>> @(2,5..10)
You need three dots, not two.
Damian
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
On 21 March 2012 22:09, Damian Conway 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 lo
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
> 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 th
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 li
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 th
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 a
"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 vari
16 matches
Mail list logo