cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Is it possible to create noncontinuous range variable?

ifomenko
15-Moonstone

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

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:ifomenko)

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

View solution in original post

15 REPLIES 15

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.

RichardJ
19-Tanzanite
(To:ifomenko)

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.

ifomenko
15-Moonstone
(To:RichardJ)

Very sad it will simplify worksheet a lot

-MFra-
21-Topaz II
(To:ifomenko)

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.

ifomenko
15-Moonstone
(To:-MFra-)

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

-MFra-
21-Topaz II
(To:-MFra-)

You may store the indexes, known a priori and with variable integer  increment, in a vector V and then, with a loop index j, recall k=V[j], and then work on the vector U[k]

The previous  attached file is the answer to another similar problem solved some months ago (proposed by aimtaz)

ifomenko
15-Moonstone
(To:-MFra-)

Your file contains a lot of files.Please attach only one).

-MFra-
21-Topaz II
(To:ifomenko)

Simplified version:

ForIgorFormenko.jpg

StuartBruff
23-Emerald II
(To:ifomenko)

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

ifomenko
15-Moonstone
(To:StuartBruff)

One string form.png

LucMeekes
23-Emerald III
(To:ifomenko)

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

ifomenko
15-Moonstone
(To:LucMeekes)

Thank you very much LucMeekes.I forgot about this opportunity at all))).40 years old is not so good as 20)))

LucMeekes
23-Emerald III
(To:ifomenko)

Which can be presented a little smaller by using i for the vector and . for its index (You'll have to use [Ctl-Shft-K] to enter the . symbol):

Top Tags