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

Is it possible to create noncontinuous range variable?

  • October 19, 2016
  • 5 replies
  • 4266 views

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

Best answer by LucMeekes

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

5 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.

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.

ifomenko1-VisitorAuthor
1-Visitor
October 19, 2016

Very sad it will simplify worksheet a lot

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.

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))

24-Ruby IV
October 19, 2016

24-Ruby IV
October 19, 2016

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

ifomenko1-VisitorAuthor
1-Visitor
October 19, 2016

One string form.png

LucMeekes23-Emerald IVAnswer
23-Emerald IV
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