Manipulaton of Rings

Hi,

I am trying to figure out the following:

I want an easy way to create a ring such as

(ring 1, 2, 2, 3, 3, 4, 4, 5)

My idea is firsty to make a line

r = (line 1,5)

double secondly all values of the resulting ring:

s = r.? # result shoud be => (ring 1, 1, 2, 2, 3, 3, 4, 4)

and then thirdly get rid of the first and the last element:

s.drop(0).butlast

But I don’t know how to achieve step number 2. Can anybody help?

Cheers
Martin

How about this:

(range 2, 5).stretch(2).unshift(1).push(5)
2 Likes

Great!

Actually I would prefer:

(line 1,5).stretch(2).drop(1).butlast

But that seems to only be a matter of personal taste and memorability.

With stretch you did get me going! Thanks!

1 Like