On 9/10/2009 12:28:04 PM, VFO wrote:
I think a range variable is (must be) one special form of a vectors.
We can have possibility to input in sheet:
v:=stack(1, 1.5, 2, 2.5, 3)
v[1=1.5
or
v:=1, 1.5 .. 3I think the distinction is important (at the moment).
One advantage of a range variable is that it consumes minimal memory, whereas a vector would consumes as much memory as is needed to hold the corresponding number of values.
One thing I would like to see is the concept of the range specification generalized to other data types and more complex sequences (eg strings and quadratics - see
http://collab.mathsoft.com/read?114862,12 )
I'd also like to consider extending the concept of 'sequences' (see below) into the common usage. Sequences are currently only used in program for loops, but it would be nice to see them introduced as a formal data type that could be assigned to a variable (ie, extending the concept of a 'range variable' to become a 'sequence variable')
I'd also like to be a little bit heretical and suggest that the 'bug' you reported above may be worth looking at as a 'feature' instead
🙂 Try
a:=1.0, 1.2 .. 2.0
k:=0..30
b[k:=a[k
j:=0..10
c[j:=a[j
This allows the generation of several vectors with the same increments but different lengths from a single specification. Yes, it will undoubtedly confuse many people, but given that range variables v vectors cause confusion anyway perhaps the extra utility will make the 'learning curve' confusion worthwhile.
Stuart
Looking at what we have in M14, then:
A range specification is a data type that takes the form 'start_value, next_value .. last_value' or 'start_value .. last_value', where start_value is a real number and ',' and '..' are part of the specification. If next_value is omitted then a value of start_value+1 is assumed.
A range specification is shorthand for a linear sequence of values lying between start_value and last_value in increments of next_value-start_value.
A variable that holds a range specification is referred to as a 'range variable'.
A sequence is a data type that takes the form 'value_0, value_1{,value_2 ... }', where value_n is of any data type (including a range specification) and ',' is part of the specification. '{','}' and '...' indicate that the sequence may optionally have more than two values. Note that where a value is a full form range specification, then it must be enclosed in parentheses (eg, '1,5, (0.1,0.2..0.9), 7')