Skip to main content
19-Tanzanite
September 26, 2023
Solved

How to extract an element that has been defined as a range from a vector?

  • September 26, 2023
  • 1 reply
  • 1579 views

Hello,

How to extract for example the 13th element from below?

Cornel_0-1695736939181.png

Cornel_1-1695736945839.png

Cornel_2-1695736952911.png

Cornel_3-1695737002942.png

Cornel_5-1695737095494.png

 

Cornel_0-1695737359209.png

Best answer by terryhendicott

Hi,

The creation of x makes it a range variable not a vector of scalars.  An undocumented trick to turn the range into a scalar vector is to use inline equals in the definition.

Capture.JPG

1 reply

21-Topaz II
September 26, 2023

Hi,

The creation of x makes it a range variable not a vector of scalars.  An undocumented trick to turn the range into a scalar vector is to use inline equals in the definition.

Capture.JPG

Cornel19-TanzaniteAuthor
19-Tanzanite
September 26, 2023

I have a question here: can this undocumented trick fail? And if yes, then when can it fail?

21-Topaz II
September 26, 2023

Never had the trick fail.  Here is the "correct" way

Capture2.JPG