Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Two simple things you can do (also in Perl 5):
You can get rid of the temporary $t by using list assignment:
Or you can resort to recursion, ignoring your boundaries to the golf court:
For none of these I can see something where Perl 6 really plays its strengths. So maybe something completely else? This might work, but since nobody implements infix:<...> yet, I couldn't test it:
For example for gcd(42, 24) it would produce the list 42, 24, 18, 6. During the next call to the block it the $^x % $^y returns 0, and the block the empty list, ending the creation of the list. The last element is the gcd. In reply to Re: Euclidean algorithm Golf in Perl 6
by moritz
|
|