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.1.0.8 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.7 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.6 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.5 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.4 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.3 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.2 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.1 tracks/perl6/exercises/anagram/Example.pm
trackler-2.1.0.0 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.55 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.54 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.53 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.52 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.51 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.50 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.49 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.48 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.47 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.46 tracks/perl6/exercises/anagram/Example.pm
trackler-2.0.8.45 tracks/perl6/exercises/anagram/Example.pm