Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,12 +1,11 @@
|
|||
/*REXX program maps a number from one range to another range. */
|
||||
|
||||
rangeA = '0 10'
|
||||
rangeB = '-1 0'
|
||||
|
||||
do j=0 to 10
|
||||
say right(j,3) ' maps to ' mapRange(rangeA, rangeB, j)
|
||||
/*REXX program maps a range of numbers from one range to another range. */
|
||||
rangeA = 0 10 /*or: rangeA = ' 0 10 ' */
|
||||
rangeB = -1 0 /*or: rangeB = " -1 0 " */
|
||||
parse var RangeA L H
|
||||
inc=1
|
||||
do j=L to H by inc*(1-2*sign(H<L)) /*BY: +inc │ -inc) */
|
||||
say right(j,digits()) ' maps to ' mapRange(rangeA,rangeB,j)
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
|
||||
/*──────────────────────────────────MAPRANGE subroutine─────────────────*/
|
||||
mapRange: procedure; arg a1 a2,b1 b2,x; return b1+(x-a1)*(b2-b1)/(a2-a1)
|
||||
mapRange: procedure; arg a1 a2,b1 b2,s; return b1+ (s-a1)*(b2-b1)/(a2-a1)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
/*REXX program maps a number from one range to another range. */
|
||||
|
||||
do j=0 to 10
|
||||
say right(j,3) ' maps to ' mapRange(0 10, -1 0, j)
|
||||
/*REXX pgm maps a range of numbers from one range to another with inc=½.*/
|
||||
rangeA = 10 0 /*or: rangeA = ' 10 0 ' */
|
||||
rangeB = -1 0 /*or: rangeB = " -1 0 " */
|
||||
parse var RangeA L H /*note the LOW & HIGH values in A*/
|
||||
inc= 1/2 /*use a different step size (inc)*/
|
||||
do j=L to H by inc*(1-2*sign(H<L)) /*BY: +inc │ -inc) */
|
||||
say right(j,9) ' maps to ' mapRange(rangeA,rangeB,j)
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
|
||||
/*──────────────────────────────────MAPRANGE subroutine─────────────────*/
|
||||
mapRange: procedure; arg a1 a2,b1 b2,x; return b1+(x-a1)*(b2-b1)/(a2-a1)
|
||||
mapRange: procedure; arg a1 a2,b1 b2,s; return b1+ (s-a1)*(b2-b1)/(a2-a1)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
/*REXX program maps a number from one range to another range. */
|
||||
|
||||
rangeA = '0 10'; parse var rangeA a1 a2
|
||||
rangeB = '-1 0'; parse var rangeB b1 b2
|
||||
|
||||
do j=0 to 10
|
||||
say right(j,3) ' maps to ' b1+(x-a1)*(b2-b1)/(a2-a1)
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
/*REXX program maps a range of numbers from one range to another range. */
|
||||
rangeA = 0 10
|
||||
rangeB = -1 0
|
||||
inc=1
|
||||
call mapRange rangeA, RangeB, inc
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────MAPRANGE subroutine─────────────────*/
|
||||
mapRange: procedure; parse a1 a2, b1 b2, inc
|
||||
do s=a1 to a2 by inc*(1-2*sign(a2<a1)) /*BY: +inc │ -inc */
|
||||
say right(s,digits()) ' maps to ' b1+(s-a1)*(b2-b1)/(a2-a1)
|
||||
end /*s*/ /*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
|
||||
return /*════════════t════════════*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue