Rosetta Code/Run examples: Difference between revisions

→‎{{header|Raku}}: Update task for renamed language.
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(→‎{{header|Raku}}: Update task for renamed language.)
Line 589:
(formerly Perl 6)
{{works with|Rakudo|2018.03}}
This is a fairly comprehensive task code runner. It is set up to work for Perl 6Raku by default, but has basic configurations to run Perl, Python, Tcl and Go tasks as well. It can be easily tweaked to work with other languages by adding a load-lang('whatever'){} routine similar to the Perl6Raku, Perl, Python, Tcl and Go ones. (And ensuring that the appropriate compiler is installed and accessible.) There is so much variation to the task requirements and calling conventions that it would be problematic to make a general purpose, language agnostic code runner so some configuration is necessary to make it work with other languages.
 
(Note that there is no dependency download code nor resource hash for Python and Go, though they can run a remarkable number of tasks without.)
 
By default, this will download the Perl 6Raku section of any (every) task that has a Perl 6Raku example, extract the code blocks and attempt to run them. Many tasks require files or user interaction to proceed, others are not complete runnable code blocks (example code fragments), some tasks run forever. To try to deal with and compensate for this, this implementation can load a %resource hash that will: supply input files where necessary, skip unrunnable code fragments, limit long and/or infinite running blocks, supply user interaction code where possible, and skip blocks where user interaction is unavoidable.
 
There are several command line options to control its actions. See the README in the repository for details.
Line 612:
 
#####################################
say "Version = 2020-0203-16T0115T12:0015:3331";
#####################################
 
Line 621:
unit sub MAIN(
Str $run = '', #= Task or file name
Str :$lang = 'perl6raku', #= Language, default perl6raku - should be same asused into <langload *>configuration markupsettings
Int :$skip = 0, #= Skip # to continue partially into a list
Bool :f(:$force), #= Override any task skip parameter in %resource hash
Line 848:
" Did you perhaps mean:\n\n\t" ~
@tasknames.grep( {.lc.contains($title.lc) or dld($_, $title) < (5 min $title.chars)} ).join("\n\t");
} # Damerau Levenshtein distance ^^^
}
 
 
multi check-dependencies ($fn, 'perl6') {
Line 858 ⟶ 857:
if $module eq any('v6', 'v6.c', 'v6.d', 'nqp', 'NativeCall', 'Test') or $module.contains('MONKEY')
or $module.contains('experimental') or $module.starts-with('lib') or $module.contains('from<Perl5>') {
print %c<dep>;
say 'ok, no installation necessary: ', $module;
print %c<clr>;
next;
}
my $installed = $*REPO.resolve(CompUnit::DependencySpecification.new(:short-name($module)));
Line 905 ⟶ 904:
 
multi check-dependencies ($fn, $unknown) {
note "Sorry, don't know how to handle dependanciesdependencies for $unknown language."
};
 
multi load-lang ('perl6raku') { ( # Language specific variables. Adjust to suit.
language => 'Perl_6Raku', # language category name
exe => 'perl6raku', # executable commandname to run perl6 in a shell
ext => '.p6raku', # file extension for perl6 code (optional, but nice to have)
dir => 'perl6raku', # directory to save tasks to
header => 'Perl 6Raku', # header text (=={{header|Raku}}==)
# tags marking blocks of code - spaced out to placate wiki formatter
# and to avoid getting tripped up when trying to run _this_ task.
# note that this tag only selects the syntax highlighting, continue to
# use 'perl6' until 'raku' as added on the site.
tag => rx/<?after '<lang ' 'perl6' '>' > .*? <?before '</' 'lang>'>/,
) }
Line 962 ⟶ 963:
<pre>Retrieving tasks
1) Determine if a string is numeric
Getting code from: http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Perl_6Raku
 
Testing Determine_if_a_string_is_numeric
Line 1,006 ⟶ 1,007:
<pre>Retrieving tasks
1 Lucky_and_even_lucky_numbers
Getting code from: http://rosettacode.org/wiki/Lucky_and_even_lucky_numbers#Perl_6Raku
 
Testing Lucky_and_even_lucky_numbers
10,327

edits