Re: Meditations on a Loop

2009-05-26 Thread Patrick R. Michaud
On Tue, May 26, 2009 at 04:10:45PM -0700, yary wrote: > On Tue, May 26, 2009 at 1:57 PM, Patrick R. Michaud > wrote: > > On Mon, May 25, 2009 at 12:37:34PM -0700, yary wrote: > > How about...? > > > >    sub odd { ^$a % 2 } > typo. "sub odd {$^a % 2}" works (caret goes between "$" and "a") Corre

Re: Meditations on a Loop

2009-05-26 Thread John M. Dlugosz
yary not.com-at-gmail.com |Perl 6| wrote: I was wondering why the perl5 example didn't work in p6- $_ is a contextual variable, so why doesn't the body of "odd" get its $_ value from grep in something like this: sub odd_a { $_ % 2} If you make it a formally declared "sub", then you have to

Re: Meditations on a Loop

2009-05-26 Thread yary
On Tue, May 26, 2009 at 1:57 PM, Patrick R. Michaud wrote: > On Mon, May 25, 2009 at 12:37:34PM -0700, yary wrote: > How about...? > >    sub odd { ^$a % 2 } typo. "sub odd {$^a % 2}" works (caret goes between "$" and "a") >    say grep &odd, 0..6; nice. I need to learn the differences between ca

Re: Meditations on a Loop

2009-05-26 Thread Patrick R. Michaud
On Mon, May 25, 2009 at 12:37:34PM -0700, yary wrote: > That's an enjoyable and educational read, thanks! > > There's one form under TMTOWTDI that I'd like to see, but can't figure > out myself. It's the version analogous to this perl5 snippet- > > sub odd {$_ % 2} > say grep odd,0..6; > > -w

Re: Meditations on a Loop

2009-05-25 Thread yary
That's an enjoyable and educational read, thanks! There's one form under TMTOWTDI that I'd like to see, but can't figure out myself. It's the version analogous to this perl5 snippet- sub odd {$_ % 2} say grep odd,0..6; -where the line that filters the list mentions no variables at all, and "

Re: Meditations on a Loop

2009-05-22 Thread John M. Dlugosz
Sartak sartak-at-gmail.com |Perl 6| wrote: On Fri, May 22, 2009 at 7:52 PM, John M. Dlugosz <2nb81l...@sneakemail.com> wrote: That sounds like a circular reference problem. If the dot is a simple multi sub and is expected to dispatch based on type (different types may have different dispatch

Re: Meditations on a Loop

2009-05-22 Thread Sartak
On Fri, May 22, 2009 at 7:52 PM, John M. Dlugosz <2nb81l...@sneakemail.com> wrote: > That sounds like a circular reference problem.  If the dot is a simple multi > sub and is expected to dispatch based on type (different types may have > different dispatchers), what "type" are you keying off of to

Re: Meditations on a Loop

2009-05-22 Thread John M. Dlugosz
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Sex, 2009-05-22 às 18:27 -0500, John M. Dlugosz escreveu: Daniel Ruoso wrote: That's because dot is an operator as well and might be subject to be overriden... but don't tell anyone that... You mean by installing a different dis

Re: Meditations on a Loop

2009-05-22 Thread Daniel Ruoso
Em Sex, 2009-05-22 às 18:27 -0500, John M. Dlugosz escreveu: > Daniel Ruoso wrote: > > That's because dot is an operator as well and might be subject to be > > overriden... but don't tell anyone that... > You mean by installing a different dispatcher for the object? By > hooking the grammar at a

Re: Meditations on a Loop

2009-05-22 Thread John M. Dlugosz
Daniel Ruoso wrote: Em Qui, 2009-05-21 às 20:21 -0500, John M. Dlugosz escreveu: but it was crudly inserted, so just before it the text still reads, "The "dot" form and the indirect object form DEFAULT to method calls. All other prefix calls DEFAULT to subroutine calls." (emphasis mine),

Re: Meditations on a Loop

2009-05-22 Thread Daniel Ruoso
Em Qui, 2009-05-21 às 20:21 -0500, John M. Dlugosz escreveu: > but it was crudly inserted, so just before it the text still reads, "The > "dot" form and the indirect object form DEFAULT to method calls. All > other prefix calls DEFAULT to subroutine calls." (emphasis mine), That's because dot i

Re: Meditations on a Loop

2009-05-22 Thread John M. Dlugosz
Patrick R. Michaud pmichaud-at-pobox.com |Perl 6| wrote: The page currently says: "The reason this [.prime] works is because the method-call syntax will call an ordinary non-member sub also." I think this is no longer the case (and hasn't been for some time). Pm Wow, that's new

Re: Meditations on a Loop

2009-05-22 Thread Jon Lang
On Fri, May 22, 2009 at 5:34 AM, Timothy S. Nelson wrote: > On Fri, 22 May 2009, Jonathan Worthington wrote: > >> Daniel Ruoso wrote: >>> >>> Em Sex, 2009-05-22 às 01:25 -0500, John M. Dlugosz escreveu: >>>   �...@primes = do $_ if prime($_) for 1..100; becomes   �...@primes = $_ wh

Re: Meditations on a Loop

2009-05-22 Thread Timothy S. Nelson
On Fri, 22 May 2009, Jonathan Worthington wrote: Daniel Ruoso wrote: Em Sex, 2009-05-22 às 01:25 -0500, John M. Dlugosz escreveu: @primes = do $_ if prime($_) for 1..100; becomes @primes = $_ when prime($_) for 1..100; you gained one stroke, it's certainly better... I think it's t

Re: Meditations on a Loop

2009-05-22 Thread Jonathan Worthington
Daniel Ruoso wrote: Em Sex, 2009-05-22 às 01:25 -0500, John M. Dlugosz escreveu: @primes = do $_ if prime($_) for 1..100; becomes @primes = $_ when prime($_) for 1..100; you gained one stroke, it's certainly better... I think it's time to play golf with Perl 6 already ;) joke

Re: Meditations on a Loop

2009-05-22 Thread Daniel Ruoso
Em Sex, 2009-05-22 às 01:25 -0500, John M. Dlugosz escreveu: > @primes = do $_ if prime($_) for 1..100; > becomes > @primes = $_ when prime($_) for 1..100; you gained one stroke, it's certainly better... I think it's time to play golf with Perl 6 already ;) jokes aside, "$_ when prime($_

Re: Meditations on a Loop

2009-05-21 Thread Jon Lang
On Thu, May 21, 2009 at 11:25 PM, John M. Dlugosz <2nb81l...@sneakemail.com> wrote: > Larry Wall larry-at-wall.org |Perl 6| wrote: >> >> And since the "when" modifier counts as a conditional, you can rewrite >> >>    grep Dog, @mammals >> >> as >> >>    $_ when Dog for @mammals; >> >> So perhaps wi

Re: Meditations on a Loop

2009-05-21 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: And since the "when" modifier counts as a conditional, you can rewrite grep Dog, @mammals as $_ when Dog for @mammals; So perhaps will see a lot of subtypes used this way: subset Odd if Int where { $_ % 2 }; @evens = ($_ * 2 whe

Re: Meditations on a Loop

2009-05-21 Thread Carl Mäsak
John (>): > What is "Userdocs for Christmas"?  Someone have a link? So, "Userdocs for Christmas", also known as U4X, is an effort to create both comprehensive, consistent user documentation, and the means to access this documentation efficiently and easily. You asked about U4X the other day, whic

Re: Meditations on a Loop

2009-05-21 Thread John M. Dlugosz
What is "Userdocs for Christmas"? Someone have a link? Carl Mäsak cmasak-at-gmail.com |Perl 6| wrote: Timothy (>), John (>>): If you would be so kind, please take a look at . I spent a couple days on this, and besides needing it checked for

Re: Meditations on a Loop

2009-05-21 Thread Daniel Ruoso
Em Qui, 2009-05-21 às 21:33 -0300, Daniel Ruoso escreveu: > my @x = map { $_ * 2 for 1,2,3 }, 1,2,3; > say @x[0]; # 1; > say @x[0;0]; # ERROR > say @x[1]; # 1; > say @x[1;0]; # ERROR er... there should be a 2 as output of the fourth line there... daniel

Re: Meditations on a Loop

2009-05-21 Thread Daniel Ruoso
Em Qua, 2009-05-20 às 19:55 -0500, John M. Dlugosz escreveu: > If you would be so kind, please take a look at > . I spent a couple days > on this, and besides needing it checked for correctness, found a few > issues as well as more food for though

Re: Meditations on a Loop

2009-05-21 Thread Daniel Ruoso
Em Qua, 2009-05-20 às 20:58 -0500, Patrick R. Michaud escreveu: > On Wed, May 20, 2009 at 07:55:55PM -0500, John M. Dlugosz wrote: > > If you would be so kind, please take a look at > > . > "The reason this [.prime] works is because the method

Re: Meditations on a Loop

2009-05-21 Thread Carl Mäsak
Timothy (>), John (>>): >> If you would be so kind, please take a look at >> .  I spent a couple days on >> this, and besides needing it checked for correctness, found a few issues as >> well as more food for thought. > >        John, I very much enjo

Re: Meditations on a Loop

2009-05-21 Thread Larry Wall
On Wed, May 20, 2009 at 07:55:55PM -0500, John M. Dlugosz wrote: > If you would be so kind, please take a look at > . I spent a couple days > on this, and besides needing it checked for correctness, found a few > issues as well as more food for

Re: Meditations on a Loop

2009-05-20 Thread Timothy S. Nelson
On Wed, 20 May 2009, John M. Dlugosz wrote: If you would be so kind, please take a look at . I spent a couple days on this, and besides needing it checked for correctness, found a few issues as well as more food for thought. John, I ve

Re: Meditations on a Loop

2009-05-20 Thread Patrick R. Michaud
On Wed, May 20, 2009 at 07:55:55PM -0500, John M. Dlugosz wrote: > If you would be so kind, please take a look at > . The page currently says: "The reason this [.prime] works is because the method-call syntax will call an ordinary non-m

Re: Meditations on a Loop

2009-05-20 Thread Austin Hastings
You write: > I’m not sure what the heart of Perl 6 would be, but I think we’ve identified the spleen > with the |Capture|. In the human body, most people have no idea what the spleen does. > It sits there out of the way doing its thing, and we can’t live without it. I, along with a host of o

Meditations on a Loop

2009-05-20 Thread John M. Dlugosz
If you would be so kind, please take a look at . I spent a couple days on this, and besides needing it checked for correctness, found a few issues as well as more food for thought. --John P.S. contains some humor.