Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Map-range/Go/map-range-1.go
Normal file
19
Task/Map-range/Go/map-range-1.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type rangeBounds struct {
|
||||
b1, b2 float64
|
||||
}
|
||||
|
||||
func mapRange(x, y rangeBounds, n float64) float64 {
|
||||
return y.b1 + (n - x.b1) * (y.b2 - y.b1) / (x.b2 - x.b1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
r1 := rangeBounds{0, 10}
|
||||
r2 := rangeBounds{-1, 0}
|
||||
for n := float64(0); n <= 10; n += 2 {
|
||||
fmt.Println(n, "maps to", mapRange(r1, r2, n))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue