Sha256: 46195dca5992e0fb6f78097903e3ab821a486749ef94d15585d00cdff19f2a83

Contents?: true

Size: 347 Bytes

Versions: 156

Compression:

Stored size: 347 Bytes

Contents

unit module Anagram:ver<1>;

sub match-anagrams ($word, @words) is export {
  my @results;
  my $canonical = canonize($word);
  for @words -> $w {
    next if $w.lc eq $word.lc;
    my $try = canonize($w);
    if $try eq $canonical {
      @results.push: $w;
    }
  }
  @results;
}

sub canonize ($str) {
  (($str.lc.split('')).sort).join('');
}

Version data entries

156 entries across 156 versions & 1 rubygems

Version Path
trackler-2.0.8.44 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.43 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.42 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.41 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.40 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.39 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.38 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.37 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.36 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.35 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.34 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.33 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.32 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.31 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.30 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.29 tracks/perl6/exercises/anagram/Example.pm