Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jhuni (9050)

  (email not shown publicly)
Yahoo! ID: (Add User, Send Message)

Journal of jhuni (9050)

Friday March 19, 2010
06:21 AM

More Rosetta code written in Perl6

[ #40253 ]

I added a solution to the dot product, which it turns out was very easy knowing Perl6 meta operators:

[+] ( @a <<*>> @b )

Another problem I worked on is this missing permutations problem, which I solved using cross operators, yet it still doesn't feel that elegant to repeat things four times:

[X~] @letters = @letters X~ @letters X~ @letters X~ @letters

I would've used the [X~] operator, however, it does not seem to work in any implementation yet, so instead I wrote things like on the right hand side, which is quite messy. The only other thing which is sort of interesting is the code to check duplicates. I forget about the uniq function for a while so I wrote this messy code to check for duplicates:

sub lacksDuplicates($str) {

    my @chars = $str.split('');
    my @pastValues;

    for @chars -> $char {

        return ?(0) if $char eq any @pastValues;


    return ?(1);


Fortunately we have uniq so I wrote something more pleasant instead:

.chars == .split('').uniq.elems
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.