The range of a set of numbers is the lowest value subtracted from the highest value. This tutorial explains how to find the range given a list.
For this tutorial, the following variables and list will be required:
(least)— Holds the the lowest number
(greatest)— Holds the the highest number
(i)— A counter variable
(range)— Holds the answer
(numbers :: list)— The list in which all the values are kept
First the least and greatest values in the list must be found. This can be done by comparing each number but the first with the least and greatest numbers that have been seen so far:
set [least v] to (item (1 v) of [numbers v]) set [greatest v] to (item (1 v) of [numbers v]) set [i v] to  repeat ((length of [numbers v]) - (1)) if <(item (i) of [numbers v]) < (least)> then set [least v] to (item (i) of [list of numbers v]) end if <(item (i) of [numbers v]) > (greatest)> then set [greatest v] to (item (i) of [list of numbers v]) end change [i v] by (1) end
The final step simply subtracts the lowest value from the highest value and sets
(range) to that value.
set [range v] to ((greatest) - (least))
In this method, the first step is sorting the list from least to greatest. Then, add this script to the bottom:
set [range v] to ((item (last v) of [numbers v]) - (item (1 v) of [numbers v]))
The answer is stored in