Map range: Difference between revisions

Added Quackery.
m (syntax highlighting fixup automation)
(Added Quackery.)
Line 2,701:
10 maps to 0
>>> </syntaxhighlight>
 
=={{header|Quackery}}==
 
As Quackery does not support reals, the function takes the argument s as a decimal string, and returns the result, t as a rational number.
 
<syntaxhighlight lang="Quackery"> [ $ "bigrat.qky" loadfile ] now!
 
[ do over -
2swap
do over -
unrot
dip [ $->v drop ]
n->v v-
rot n->v v/
rot n->v v*
rot n->v v+ ] is maprange ( $ [ [ --> n/d )
 
$ "0 1 2 3 4 5 6 7 8 9 10"
nest$
witheach
[ dup echo$ say " maps to "
' [ 0 10 ] ' [ -1 0 ] maprange
7 point$ echo$ cr ]</syntaxhighlight>
 
{{out}}
 
<pre>0 maps to -1
1 maps to -0.9
2 maps to -0.8
3 maps to -0.7
4 maps to -0.6
5 maps to -0.5
6 maps to -0.4
7 maps to -0.3
8 maps to -0.2
9 maps to -0.1
10 maps to 0</pre>
 
=={{header|R}}==
<syntaxhighlight lang="rsplus">tRange <- function(aRange, bRange, s)
1,462

edits