Jump to content

# Double loop

This topic is 2826 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

not sure what to call this but I would like to turn these two arrays:

array1:  A, B, C

array2:  1, 2, 3, 4, 5, 6, 7, 8

into this:

1A, 2B, 3C,

4A, 5B, 6C,

7A, 8B

Was playing with:

GetValue ( array2 ; loop  ) &  GetValue ( array1 ; mod ( loop ; ValueCount ( array1 ) )  )

Just get stuck on

mod ( 3 ; 3 )

which I can handle with an if statement but would rather let math solve it.

##### Share on other sites

It works with Zero indexed arrays... So your second half should be  ... &  GetValue(array1; (mod(loop-1;valueCount(array1))+1)

loop -1 will simulate zero index array and give you the correct result if you do some shifting:

mod(0;3) = 0 ->add 1 to get 1 (a)

mod(1;3)=1 -> 2(

mod(2;3)  = 2 >-3©

Hope this helps.

##### Share on other sites

excellent.... thanks GisMo

##### Share on other sites

Hi Gismo,

We have a Code button that will allow you to post your code so that it look likes you intended. it is the <>  above in the Reply to this topic.

##### Share on other sites

@rivet, glad that did the trick for you!

@Lee, Thanks....now where is the "edit" button on my post?

##### Share on other sites

It should appear, along with (Report Blog this, Edit MultiQuote and Quote very light gray in the body.

If you don’t see them, just make a new reply to this post and use the Code button and repost the code in it.

Edited by Lee Smith
##### Share on other sites

@Lee I don't see it for my first post, but I do see them for my recent post earlier today. Is there a reason for that?  I'll repost my answer below with code brackets.

Answer:

GetValue(array1; (mod(loop-1;valueCount(array1))+1)

It works with Zero indexed arrays... So your second half should be  ... &  GetValue(array1; (mod(loop-1;valueCount(array1))+1)

loop -1 will simulate zero index array and give you the correct result if you do some shifting:

mod(0;3) = 0 ->add 1 to get 1 (a)

mod(1;3)=1 -> 2(

mod(2;3)  = 2 >-3©

Hope this helps.

##### Share on other sites

@Lee I don't see it for my first post, but I do see them for my recent post earlier today. Is there a reason for that?

"

I think there is a time limit for members to edit their post.

My guess is 24 hours, and or if there has been replies to your post.

##### Share on other sites

This topic is 2826 days old. Please don't post here. Open a new topic instead.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
×
×
• Create New...

## Important Information

By using this site, you agree to our Terms of Use.