Four is the number of letters in the ...: Difference between revisions
Content added Content deleted
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: | Line 394: | ||
sub alpha { my($s) = @_; $s =~ s/\W//gi; length $s } |
sub alpha { my($s) = @_; $s =~ s/\W//gi; length $s } |
||
sub no_c { my($s) = @_; $s =~ s/,//g; return $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" } |
sub count { length(join ' ', @sentence[0..-1+$_[0]]) . " characters in the sentence, up to and including this word.\n" } |
||
Line 405: | Line 405: | ||
print "\n" . count(201) . "\n"; |
print "\n" . count(201) . "\n"; |
||
for (1e3, 1e4, 1e5, 1e6) { |
for (1e3, 1e4, 1e5, 1e6, 1e7) { |
||
extend_to($_); |
extend_to($_); |
||
print |
print |
||
Line 422: | Line 422: | ||
1203 characters in the sentence, up to and including this word. |
1203 characters in the sentence, up to and including this word. |
||
One thousandth word, 'in' has 2 characters. |
One thousandth word, 'in' has 2 characters. |
||
6249 characters in the sentence, up to and including this word. |
|||
Ten thousandth word, 'in' has 2 characters. |
Ten thousandth word, 'in' has 2 characters. |
||
64097 characters in the sentence, up to and including this word. |
|||
One hundred thousandth word, ' |
One hundred thousandth word, 'one' has 3 characters. |
||
659455 characters in the sentence, up to and including this word. |
|||
One millionth word, ' |
One millionth word, 'the' has 3 characters. |
||
7113560 characters in the sentence, up to and including this word. |
|||
Ten millionth word, 'thousand' has 8 characters. |
|||
70995729 characters in the sentence, up to and including this word.</pre> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |