Re: How to write this properly in Perl 6?

2009-05-28 Thread Cosimo Streppone
In data 28 mai 2009 alle ore 00:13:19, Mark J. Reed markjr...@gmail.com ha scritto: You can write a sub to return the next step: sub bondigi { state $n=1; return (Bon Digi Bon Digi, Bon xx $n, Digi xx $n++); } Nahh. That's too easy... It's not fun :-) but I think an idiomatic Perl 6

Re: How to write this properly in Perl 6?

2009-05-28 Thread Carl Mäsak
Mark (): but I think an idiomatic Perl 6 solution would have a proper lazy Iterator.  How do we write one of those? Like this, I think: $ perl6 -e '.say for gather { my $n = 1; loop { take bon digi bon digi; take bon for ^$n; take digi for ^$n; ++$n } }' That currently parses in Rakudo, but

Re: How to write this properly in Perl 6?

2009-05-28 Thread Cosimo Streppone
In data 27 mai 2009 alle ore 23:46:40, John M. Dlugosz 2nb81l...@sneakemail.com ha scritto: Anything in the existing implementation that's hostile to Perl 6? Just port it over by lightly editing the text or using a p5 module importer. Yes, right, but that wouldn't use Perl 6 features. To

How to write this properly in Perl 6?

2009-05-27 Thread Cosimo Streppone
Hi cool people, the Amazing Perl 6 thread was amazing. It reminded me how Perl 6 looks interesting and fun. So... how can I write properly, for some meaning of properly, the Perl 6 equivalent of this: http://search.cpan.org/dist/Games-BonDigi/ ? ( if it's not clear, you can run the

Re: How to write this properly in Perl 6?

2009-05-27 Thread Carl Mäsak
Cosimo (): the Amazing Perl 6 thread was amazing. It reminded me how Perl 6 looks interesting and fun. So... how can I write properly, for some meaning of properly, the Perl 6 equivalent of this:  http://search.cpan.org/dist/Games-BonDigi/ ? Not sure if I grokked the whole set of rules,

Re: How to write this properly in Perl 6?

2009-05-27 Thread John M. Dlugosz
Cosimo Streppone cosimo-at-streppone.it |Perl 6| wrote: Hi cool people, the Amazing Perl 6 thread was amazing. It reminded me how Perl 6 looks interesting and fun. So... how can I write properly, for some meaning of properly, the Perl 6 equivalent of this:

Re: How to write this properly in Perl 6?

2009-05-27 Thread Daniel Ruoso
Em Qua, 2009-05-27 às 23:46 +0200, Carl Mäsak escreveu: Not sure if I grokked the whole set of rules, but here's a one-liner that does it: $ perl6 -e 'say (bon digi bon digi, bon xx ++$*n, digi xx $*n).join(, ) while *' It does, but it would be prettier if it was lazy... for 2..* - $n { (bon

Re: How to write this properly in Perl 6?

2009-05-27 Thread Mark J. Reed
You can write a sub to return the next step: sub bondigi { state $n=1; return (Bon Digi Bon Digi, Bon xx $n, Digi xx $n++); } but I think an idiomatic Perl 6 solution would have a proper lazy Iterator. How do we write one of those?