Simple renumbering exercise

I have a list from 1 to 20. I want to renumber every element starting with 8 and above to a new sequence starting at 15.

So far I’m able to get the starting element of the new sequence but I’m kindda stuck there :frowning: any help would be much appreciated

 

20160209-3

If I understood correctly…

Vikram i LOVE you solution. a>=X?a-8+Y:a; A is the value im looking for >= bigger or equal to X What’s the ? for? A - 8 (why is it 8)? +Y the value i want to add :a gives me the final value Am i right?

 

I endedup using that

n>=X?(n-X)+Y:n;

 

Still wondering what the ? is for?

Here’s what i came up with so far

n>=X&&n<=Y?(n-X)+Y:n;

 

Next step is to truncate the list to only have the modified value

The ? and : in a conditional statement separates the various arguments.

(test)?(if true,this result):(if false, this result)

To truncate the list you might need to do something like this.

20160209-3a

ahhh make sense. Can i nest another if, say using >= ?

You can nest conditional statements within (if true, this result) and (if false, this result)

It could begin to get complicated and confusing.

Im just trying to combine those 2

n<=X?(n-X)+Z:n

n>=Y?(n-Y)+Z:n

 

Basically i want to renumber but only withing a range. Im sure you wil come up with a better solution ahahahah but im still curious about the code

 

 

20160209-3b

Did someone said i love you lately? :slight_smile:

Thanks a million, that was a great learning exercise for me.

Ok i speak too fast :slight_smile: but we’re close :slight_smile:

If we start at 5, then 5 needs to change to 105 and 5 to 106 right?

 

20160209-3d

Now it’s official… i love you :slight_smile:

:slight_smile:

Love is in the air.