Eban numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: I twiddle because I can...)
m (→‎{{header|Perl 6}}: update description to match)
Line 129: Line 129:
=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|Rakudo|2018.12}}
{{works with|Rakudo|2018.12}}
Modular approach, very little is hard coded. Change the order of magnitude limits to adjust the search/display ranges. Change the letter given to the nban sub to change which letter to disallow.
Modular approach, very little is hard coded. Change the $upto order-of-magnitude limit to adjust the search/display ranges. Change the letter(s) given to the nban sub to modify which letter(s) to disallow.


Demonstrate for e-ban and t-ban. Will handle multi-character 'bans' as well.
Will handle multi-character 'bans'. Demonstrate for e-ban, t-ban and subur-ban.


Directly find :
Directly find :
Line 177: Line 177:
"{$n}-ban numbers between 1,000 & 4,000: {+@j}\n{@j.gist}\n";
"{$n}-ban numbers between 1,000 & 4,000: {+@j}\n{@j.gist}\n";


for (1 .. $upto).map: { 10**$_ } -> $e {
for (1 .. $upto).map: { 10**$_ } -> $e {
my $f = @bans.first( * > $e, :k );
my $f = @bans.first( * > $e, :k );
printf "Up to %14s: %d\n",comma($e), $f ?? +@bans[^$f] !! +@bans;
printf "Up to %14s: %d\n",comma($e), $f ?? +@bans[^$f] !! +@bans;