How to resolve the algorithm Map range step by step in the Logo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Map range step by step in the Logo programming language
Table of Contents
Problem Statement
Given two ranges: where:
Write a function/subroutine/... that takes two ranges and a real number, and returns the mapping of the real number from the first to the second range. Use this function to map values from the range [0, 10] to the range [-1, 0].
Show additional idiomatic ways of performing the mapping, using tools available to the language.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Map range step by step in the Logo programming language
Source code in the logo programming language
to interpolate :s :a1 :a2 :b1 :b2
output (:s-:a1) / (:a2-:a1) * (:b2-:b1) + :b1
end
for [i 0 10] [print interpolate :i 0 10 -1 0]
You may also check:How to resolve the algorithm Percentage difference between images step by step in the Lua programming language
You may also check:How to resolve the algorithm Stable marriage problem step by step in the Ceylon programming language
You may also check:How to resolve the algorithm Weird numbers step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Arrays step by step in the Delphi programming language
You may also check:How to resolve the algorithm Search a list step by step in the Yorick programming language