September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
5
Task/Map-range/Jq/map-range-1.jq
Normal file
5
Task/Map-range/Jq/map-range-1.jq
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# The input is the value to be mapped.
|
||||
# The ranges, a and b, should each be an array defining the
|
||||
# left-most and right-most points of the range.
|
||||
def maprange(a; b):
|
||||
b[0] + (((. - a[0]) * (b[1] - b[0])) / (a[1] - a[0])) ;
|
||||
1
Task/Map-range/Jq/map-range-2.jq
Normal file
1
Task/Map-range/Jq/map-range-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
range(0;11) | maprange([0,10]; [-1, 0])
|
||||
5
Task/Map-range/Jq/map-range-3.jq
Normal file
5
Task/Map-range/Jq/map-range-3.jq
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def maprange_array(a; b):
|
||||
def _helper(a0; b0; factor): b0 + (. - a0) * factor;
|
||||
|
||||
a[0] as $a | b[0] as $b | ((b[1] - b[0]) / (a[1] - a[0])) as $factor
|
||||
| map(_helper( $a; $b; $factor) );
|
||||
Loading…
Add table
Add a link
Reference in a new issue