Rosetta Code/Count examples: Difference between revisions
→{{header|Perl 6}}: Remove progress bar; it was cute but useless. Update. Only display a limited output on the main page.
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Use a better matcher to cut down on both the false positives and false negatives) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Remove progress bar; it was cute but useless. Update. Only display a limited output on the main page.) |
||
Line 1,640:
{{works with|Rakudo|2018.03}}
Retrieves counts for both Tasks and Draft Tasks. Save / Display results as a sortable wikitable rather than a static list. Click on a column header to sort on that column. To do a secondary sort, hold down the shift key and click on a second column header. Tasks have a gray (default) background, Draft Tasks have a yellow background.
For a full output, see [[Rosetta Code/Count examples/Full output]]
<lang perl6>use HTTP::UserAgent;
use URI::Escape;
use JSON::Fast;
# Friendlier descriptions for task categories
Line 1,674 ⟶ 1,660:
my %tasks;
# clear screen
run($*DISTRO.is-win ?? 'cls' !! 'clear');
#=begin update
note 'Retrieving task information...';
for %cat.keys -> $cat {
Line 1,692 ⟶ 1,679:
my $page =
$client.get("{ $url }/index.php?title={ uri-escape .<title> }&action=raw").content;
my $count = +$page.comb(/ ^^'==' <-[\n=]>* '{{header|' \w+ \N+ '==' \
%tasks{.<title>} = {'cat' => %cat{$cat}, :$count};
print clear, 1 + $
})
}
print
note "\nTask information saved to local file: {$hashfile.IO.absolute}";
Line 1,720 ⟶ 1,707:
# Add table boilerplate and caption
$out.say:
'{|class="wikitable sortable"', "\n",
"|+ As of { Date.today } :: Tasks: { $taskcnt } ::<span style=\"background-color:#ffd\"> Draft Tasks:
"{ $draftcnt } </span>:: Total Tasks: { $count } :: Total Examples: { $total }\n",
"! Count !! Task !! Category"
;
Line 1,742 ⟶ 1,728:
}
$out.say( "|}
$out.close;
Line 1,763 ⟶ 1,749:
sub naturally ($a) { $a.lc.subst(/(\d+)/, ->$/ {0~(65+$0.chars).chr~$0},:g) }
sub clear { "\r" ~ ' ' x 100 ~ "\r" }</lang>
{{out|Abridged output}}
{|class="wikitable sortable" style="width:60em;"
|+ As of 2018-04-10 :: Tasks: 871 ::<span style="background-color:#ffd"> Draft Tasks:209 </span>:: Total Tasks: 1080 :: Total Examples: 55787
! Count !! Task !! Category
|-
|
| [[Hello%20world%2FText|Hello world/Text]]
| Task
Line 1,810 ⟶ 1,796:
| [[Function%20definition|Function definition]]
| Task
|}
=={{header|PicoLisp}}==
|