Skip to main content
1-Visitor
October 19, 2016
Solved

Is it possible to create noncontinuous range variable?

Hi all

MC15

I want to create range variable like i:=1,2,3,5 to use it in iterations like

a.i:=i for example

Now I`ve to use index vector i={1 2 3 5}T inside program loop for this.

Is it possible to create noncontinuous range variable?

Many thanks in advance

LucMeekesAnswer
23-Emerald V
October 19, 2016

While we're waiting for Stuart's request to be finally implemented in Prime version N...

you don't necessarily need to program, if you can live with...Well it's basically what Fred described above:

Success!
Luc

15 replies

23-Emerald I
October 19, 2016

The definition for a range variable precludes this:  first, second , , last.  If you need a noncontiguous step as you've described, create a vector of integers rather than a range variable.  Then you can use the integers in that vector as indices in your loop.

Translate
19-Tanzanite
October 19, 2016

Is it possible to create noncontinuous range variable?

A range variable does not store a list of values, it stores the start, the increment, and the end. So no, that is not possible.

Translate
ifomenko1-VisitorAuthor
1-Visitor
October 19, 2016

Very sad it will simplify worksheet a lot

Translate
21-Topaz II
October 19, 2016

You may store the indexes, known a priori and with variable integer  increment, in a vector and then, with a loop, recall, associating them to an integer index of an element of a vector in a matrix on which to do the calculations.

Attached there is an example quite complicated.

Translate
ifomenko1-VisitorAuthor
1-Visitor
October 19, 2016

I know about vector possibility, but in this case I need to use a loop instead of ellegant one row string))

Translate
24-Ruby IV
October 19, 2016

Translate
24-Ruby IV
October 19, 2016

Translate
23-Emerald V
October 19, 2016

Igor Fomenko wrote:

Hi all

MC15

I want to create range variable like i:=1,2,3,5 to use it in iterations like

a.i:=i for example

Now I`ve to use index vector i={1 2 3 5}T inside program loop for this.

Is it possible to create noncontinuous range variable?

Many thanks in advance

Not as you. I have a long standing request to allow such a feature, including by extending the concept of a sequence to allow arbitrary lists of values, such as 1,2,3,5 or (1..3),5.  We can already do this in a programming for loop, so this change woukd mean we could do the same thing at worksheet level using the := operator.

Stuart

Translate
ifomenko1-VisitorAuthor
1-Visitor
October 19, 2016

One string form.png

Translate
LucMeekes23-Emerald VAnswer
23-Emerald V
October 19, 2016

While we're waiting for Stuart's request to be finally implemented in Prime version N...

you don't necessarily need to program, if you can live with...Well it's basically what Fred described above:

Success!
Luc

Translate