Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Map-range/Nim/map-range.nim
Normal file
10
Task/Map-range/Nim/map-range.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import strformat
|
||||
|
||||
type FloatRange = tuple[s, e: float]
|
||||
|
||||
proc mapRange(a, b: FloatRange; s: float): float =
|
||||
b.s + (s - a.s) * (b.e - b.s) / (a.e - a.s)
|
||||
|
||||
for i in 0..10:
|
||||
let m = mapRange((0.0,10.0), (-1.0, 0.0), float(i))
|
||||
echo &"{i:>2} maps to {m:4.1f}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue