langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
8
Task/Map-range/Perl-6/map-range-1.pl6
Normal file
8
Task/Map-range/Perl-6/map-range-1.pl6
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use v6;
|
||||
# Author: P. Seebauer
|
||||
sub the_function(Range $a, Range $b, $s ) {
|
||||
my ($a1, $a2, $b1, $b2) = ($a, $b)».bounds;
|
||||
return $b1 + (($s-$a1) * ($b2-$b1) / ($a2-$a1));
|
||||
}
|
||||
|
||||
for ^11 -> $x {say "$x maps to {the_function(0..10,-1..0, $x)}"}
|
||||
7
Task/Map-range/Perl-6/map-range-2.pl6
Normal file
7
Task/Map-range/Perl-6/map-range-2.pl6
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
sub getmapper(Range $a, Range $b) {
|
||||
my ($a1, $a2, $b1, $b2) = ($a, $b)».bounds;
|
||||
return -> $s { $b1 + (($s-$a1) * ($b2-$b1) / ($a2-$a1)) }
|
||||
}
|
||||
|
||||
my &mapper = getmapper(0 .. 10, -1 .. 0);
|
||||
for ^11 -> $x {say "$x maps to &mapper($x)"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue