Sha256: ffb9581d11381638ebcaf15c9058f6bbd1beb6a4fc613e7a4853ef3e1d0883cb

Contents?: true

Size: 519 Bytes

Versions: 157

Compression:

Stored size: 519 Bytes

Contents

unit class Robot:ver<1>;

subset Name of Str where * ~~ /^<[A..Z]>**2 <[0..9]>**3$/;
has Name $.name = self.reset-name;

method reset-name {
  state Promise:D $promise = start ('AA000'..'ZZ999').pick: *;
  state Bool:D %record{Name:D};
  state Int:D $i = 0;

  if $promise.status ~~ 'Kept' {
    ($!name = $promise.result[$i++]) or die 'All names used.';
  } else {
    $!name = ('A'..'Z').roll(2).join ~ (^10).roll(3).join;
  }
  self.reset-name if %record{$!name}:exists;
  %record{$!name} = True;
  return $!name;
}

Version data entries

157 entries across 157 versions & 1 rubygems

Version Path
trackler-2.2.1.55 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.54 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.53 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.52 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.51 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.50 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.49 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.48 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.47 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.46 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.45 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.44 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.43 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.42 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.41 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.40 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.39 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.38 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.37 tracks/perl6/exercises/robot-name/Example.pm6
trackler-2.2.1.36 tracks/perl6/exercises/robot-name/Example.pm6