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.66 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.65 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.64 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.63 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.62 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.61 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.60 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.59 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.58 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.57 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.56 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.55 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.54 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.53 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.52 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.51 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.50 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.49 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.48 tracks/perl6/exercises/anagram/Example.pm6
trackler-2.2.1.47 tracks/perl6/exercises/anagram/Example.pm6