Abbreviations, automatic: Difference between revisions

m
→‎{{header|Perl 6}}: Follow Haskell example; generalize to work with any arbitrary list of words. (remove hard coded size of 7)
m (→‎{{header|Perl 6}}: Follow Haskell example; generalize to work with any arbitrary list of words. (remove hard coded size of 7))
Line 446:
 
<lang perl6>sub auto-abbreviate ( Str $string ) {
return Nil unless my @dayswords = $string.words;
my $max = @days»words.chars.max;
for 0 .. $max {
return $_ if +@dayswords».substr(0, $_).Set == 7@words;
return '∞' if $_ == $max;
}
10,333

edits