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.2.1.46 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.45 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.44 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.43 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.42 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.41 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.40 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.39 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.38 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.37 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.36 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.35 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.34 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.33 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.32 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.31 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.30 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.29 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.28 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.27 tracks/perl6/exercises/anagram/Example.pm6