Applescript : generate a new list based on existing list
If you're wanting myNewList
to return a list of lists I think you're trying to do:
set theList to {"Demo", "ok", "blabla", "demo2"}
set ColortheList to {"5cdf64", "FFFF00", "FF0080", "FF1000"}
set myNewList to {}
repeat with a from 1 to length of theList
copy ({item a of theList, item a of ColortheList}) to the end of the |myNewList|
end repeat
return myNewList
A little fun with random number
. You can modify the color selection and then randomly add to a list:
set theList to {"Demo", "ok", "blabla", "demo2", "foobar"}
set colorList to {"5cdf64", "FFFF00"}
set colorLength to length of colorList
set myNewList to {}
repeat with a from 1 to length of theList
set colorPick to random number from 1 to colorLength
copy ({item a of theList, item colorPick of colorList}) to the end of the |myNewList|
end repeat
return myNewList
If you're wanting a string approach try:
set theList to {"Demo", "ok", "blabla", "demo2"}
set ColortheList to {"5cdf64", "FFFF00", "FF0080", "FF1000"}
set myNewList to ""
repeat with a from 1 to length of theList
set result to ({item a of theList, item a of ColortheList})
set myNewList to myNewList & (result & " ")
end repeat
The above can be modified in the result
. Let me know if I'm understanding you or if you're needing something different.