RosettaCodeData/Task/Map-range/Perl-6/map-range-1.pl6

8 lines
223 B
Raku
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
sub the_function(Range $a, Range $b, $s) {
my ($a1, $a2) = $a.bounds;
my ($b1, $b2) = $b.bounds;
2013-04-10 22:43:41 -07:00
return $b1 + (($s-$a1) * ($b2-$b1) / ($a2-$a1));
}
2015-11-18 06:14:39 +00:00
for ^11 -> $x { say "$x maps to {the_function(0..10, -1..0, $x)}" }