Four is the number of letters in the ...: Difference between revisions

→‎{{header|Perl}}: Lingua::EN::Numbers puts 'and' in the ordinal/cardinal numbers. Filter them out for accurate character counts.
(Added Perl example)
(→‎{{header|Perl}}: Lingua::EN::Numbers puts 'and' in the ordinal/cardinal numbers. Filter them out for accurate character counts.)
Line 394:
 
sub alpha { my($s) = @_; $s =~ s/\W//gi; length $s }
sub no_c { my($s) = @_; $s =~ s/\ and|,//g; return $s }
sub count { length(join ' ', @sentence[0..-1+$_[0]]) . " characters in the sentence, up to and including this word.\n" }
 
Line 405:
print "\n" . count(201) . "\n";
 
for (1e3, 1e4, 1e5, 1e6, 1e7) {
extend_to($_);
print
Line 422:
1203 characters in the sentence, up to and including this word.
 
One thousandth word, 'in' has 2 characters.
60486249 characters in the sentence, up to and including this word.
 
Ten thousandth word, 'in' has 2 characters.
6105564097 characters in the sentence, up to and including this word.
 
One hundred thousandth word, 'theone' has 3 characters.
627301659455 characters in the sentence, up to and including this word.
 
One millionth word, 'fivethe' has 43 characters.
67818027113560 characters in the sentence, up to and including this word.</pre>
 
Ten millionth word, 'thousand' has 8 characters.
70995729 characters in the sentence, up to and including this word.</pre>
 
=={{header|Perl 6}}==
10,327

edits