Reference Ranges $p[s,f]

Top  Previous  Next

You can specify a range of references using the $p[s,f] notation where s is the start of the range and f is the end of the range.

 

$p=list("red","orange","yellow","green","blue","indigo","violet")

 

If you have created this list, you can create a range reference like $p[2,4]. This will list the referenced elements, in order, separated by your computer's normal separator character (usually a comma).

 

In this case, $p[2,4] will be replaced by "orange, yellow, green"

 

One example usage for range references might be with arithmetic progressions.

 

$a=range(4,1000,3)

 

This range parameter will select from the values:

 

 4, 7, 10, 13, 16 ... 994, 997, 1000

 

These numbers are in arithmetic progression.

 

$a[14] will give you the 14th number in the arithmetic progression (43)

 

$a[3,10] will produce 10, 13, 16, 19, 22, 25, 28, 31