# Repeat with a in b & c in d ?

Hi,

I guess there’s probably a post about this but I couldn’t find it (didn’t know what to search for)

I have a script similar to this one but it’s too large to post. Basically the script has 2 lists each containing the same amount of items and I want to repeat it only the same amount of items in the list times. Which is in this example 3 times. I know there isn’t an a & b used in this script but that’s because it’s a simple example.

``````set b to {1,2,3}
set d to {4,5,6}
set x to 0
repeat with a in b
repeat with c in d
set x to x + 1
end repeat
end repeat
``````

x results in 9 (which is items in b * items in d)

I’d like to have something like this,

``````repeat with a in b & c in d
end repeat
``````

so it only repeats 3 times…

Is that possible somehow?
Thanks

Hello,
It would be helpful to know what value you expect X to have at its final state”3,6,9,12,21?

3 would be nice

It sounds like you are wanting the Looping variable b and d to advance through their list in step.

I think you’ll have to use an index

``````set b to {1, 2, 3}
set d to {4, 5, 6}
set x to 0
repeat with i from 1 to count of b
set a to item i of b
set c to item i of d
set x to x + 1
end repeat
``````

After editing this comment 4 times, I got a solution

really thanks!