Rosetta Code/Count examples: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Modify to show the top 10 language completion rate instead of draft/task status which is denoted by color anyway) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Update to show sortable top 10 completion. Fix problem with with detecting examples that use non-standard markup) |
||
Line 1,793: | Line 1,793: | ||
});</lang> |
});</lang> |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|Rakudo|2018. |
{{works with|Rakudo|2018.12}} |
||
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. |
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. |
||
Line 1,800: | Line 1,800: | ||
use URI::Escape; |
use URI::Escape; |
||
use JSON::Fast; |
use JSON::Fast; |
||
unit sub MAIN ( Str $no-fetch = '' ); |
|||
# Friendlier descriptions for task categories |
# Friendlier descriptions for task categories |
||
Line 1,818: | Line 1,820: | ||
# clear screen |
# clear screen |
||
run($*DISTRO.is-win ?? 'cls' !! 'clear'); |
run($*DISTRO.is-win ?? 'cls' !! 'clear'); |
||
#=begin update |
|||
⚫ | |||
⚫ | |||
my %counts = |
my %counts = |
||
Line 1,838: | Line 1,834: | ||
my @top10 = %counts.sort( -*.value ).head(10).map: *.key; |
my @top10 = %counts.sort( -*.value ).head(10).map: *.key; |
||
# dump a copy to STDOUT, mostly for debugging purposes |
|||
⚫ | |||
⚫ | |||
⚫ | |||
say "{('①' .. '⑩')[$_]} {@top10[$_]}" for ^@top10; |
|||
⚫ | |||
say "</pre>\n"; |
|||
⚫ | |||
⚫ | |||
unless $no-fetch { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
#=end update |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
my $lc = $page.lc; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
}) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
# Load information from local file |
# Load information from local file |
||
Line 1,880: | Line 1,888: | ||
my $out = open($tablefile, :w) or die "$!\n"; |
my $out = open($tablefile, :w) or die "$!\n"; |
||
$out.say: '<pre>Top ten programming language by number of task examples completed:'; |
|||
# Show top 10 |
|||
⚫ | |||
$out.say: "{('①' .. '⑩')[$_]} {@top10[$_]}" for ^@top10; |
$out.say: "{('①' .. '⑩')[$_]} {@top10[$_]}" for ^@top10; |
||
$out.say: "</pre>\n"; |
$out.say: "</pre>\n\n<div style=\"height:40em;overflow:scroll;\">"; |
||
# Add table boilerplate and caption |
# Add table boilerplate and caption |
||
Line 1,890: | Line 1,897: | ||
"|+ As of { DateTime.new(time) } :: Tasks: { $taskcnt } ::<span style=\"background-color:#ffd\"> Draft Tasks:", |
"|+ As of { DateTime.new(time) } :: Tasks: { $taskcnt } ::<span style=\"background-color:#ffd\"> Draft Tasks:", |
||
"{ $draftcnt } </span>:: Total Tasks: { $count } :: Total Examples: { $total }\n", |
"{ $draftcnt } </span>:: Total Tasks: { $count } :: Total Examples: { $total }\n", |
||
"! |
"!Count!!Task!!{('①' .. '⑩').join('!!')}" |
||
; |
; |
||
Line 1,905: | Line 1,912: | ||
!! "| [[{uri-escape $task.key}|{$task.key}]]\n" |
!! "| [[{uri-escape $task.key}|{$task.key}]]\n" |
||
), |
), |
||
"| |
"|{ $task.value<top10>.comb.join('||') }" |
||
} |
} |
||
$out.say( "|}" ); |
$out.say( "|}\n</div>" ); |
||
$out.close; |
$out.close; |
||
Line 1,933: | Line 1,940: | ||
{{out|Abridged output}} |
{{out|Abridged output}} |
||
<pre>Top ten programming language by number of task examples: |
<pre>Top ten programming language by number of task examples completed: |
||
① Go |
① Go |
||
② Perl 6 |
② Perl 6 |
||
Line 1,946: | Line 1,953: | ||
</pre> |
</pre> |
||
<div style="height:40em;overflow:scroll;"> |
|||
{|class="wikitable sortable" |
{|class="wikitable sortable" |
||
|+ As of 2019-01- |
|+ As of 2019-01-21T22:41:28Z :: Tasks: 924 ::<span style="background-color:#ffd"> Draft Tasks:215 </span>:: Total Tasks: 1139 :: Total Examples: 59984 |
||
! |
!Count!!Task!!①!!②!!③!!④!!⑤!!⑥!!⑦!!⑧!!⑨!!⑩ |
||
|- |
|- |
||
| 405 |
| 405 |
||
| [[Hello%20world%2FText|Hello world/Text]] |
| [[Hello%20world%2FText|Hello world/Text]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 283 |
| 283 |
||
|data-sort-value="0C99 bottles of beer"| [[99%20Bottles%20of%20Beer|99 Bottles of Beer]] |
|data-sort-value="0C99 bottles of beer"| [[99%20Bottles%20of%20Beer|99 Bottles of Beer]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 276 |
| 276 |
||
| [[FizzBuzz|FizzBuzz]] |
| [[FizzBuzz|FizzBuzz]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 273 |
| 273 |
||
|data-sort-value="0D100 doors"| [[100%20doors|100 doors]] |
|data-sort-value="0D100 doors"| [[100%20doors|100 doors]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 251 |
| 251 |
||
| [[Fibonacci%20sequence|Fibonacci sequence]] |
| [[Fibonacci%20sequence|Fibonacci sequence]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 246 |
| 246 |
||
| [[Comments|Comments]] |
| [[Comments|Comments]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 239 |
| 239 |
||
| [[Factorial|Factorial]] |
| [[Factorial|Factorial]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 223 |
| 223 |
||
| [[Empty%20program|Empty program]] |
| [[Empty%20program|Empty program]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 222 |
| 222 |
||
| [[A%2BB|A+B]] |
| [[A%2BB|A+B]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|- |
|- |
||
| 214 |
| 214 |
||
| [[Function%20definition|Function definition]] |
| [[Function%20definition|Function definition]] |
||
|①||②||③||④||⑤||⑥||⑦||⑧||⑨||⑩ |
|||
| ①②③④⑤⑥⑦⑧⑨⑩ |
|||
|} |
|} |
||