> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/m/map_range.md).

# Map range

```ruby
func map_range(a, b, x) {
    var (a1, a2, b1, b2) = (a.bounds, b.bounds)
    x-a1 * b2-b1 / a2-a1 + b1
}
 
var a = 0..10
var b = -1..0
 
a.each { |x|
    say "#{x} maps to #{map_range(a, b, x)}"
}
```

#### Output:

```
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
```
