Four is the number of letters in the ...: Difference between revisions
Four is the number of letters in the ... (view source)
Revision as of 21:21, 10 September 2018
, 5 years ago→{{header|Perl}}: Lingua::EN::Numbers puts 'and' in the ordinal/cardinal numbers. Filter them out for accurate character counts.
SqrtNegInf (talk | contribs) (Added Perl example) |
Thundergnat (talk | contribs) (→{{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.
Ten thousandth word, 'in' has 2 characters.
One hundred thousandth word, '
One millionth word, '
Ten millionth word, 'thousand' has 8 characters.
70995729 characters in the sentence, up to and including this word.</pre>
=={{header|Perl 6}}==
|