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.28 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.27 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.26 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.25 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.24 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.23 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.22 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.21 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.20 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.19 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.18 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.17 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.16 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.15 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.14 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.13 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.12 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.11 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.10 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.1.0.9 tracks/perl6/exercises/anagram/Example.pm