langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
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