Hello, I’m just trying to understand the finer points of list building, and retain some semblance of sanity
My routine is supposed to take a list formatted as {1,3,5,7} and convert it to {{1}, {1, 2, 3}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6, 7}}
Unfortunately, at the moment I am getting this instead: {1, 1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, …}
If I need it to be: {{1}, {1, 2, 3}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6, 7}} is it even possible to create it this way on the fly?
Thanks for the clarification!
Here’s the routine:
set working_list to {{{1}, {3}, {5}, {7}}, {{2}, {4}, {6}, {8}}, {{9}, {10}, {11}, {12}}} --contains multiple groups of four each from 1 to n
–item 1 of working_list contains {1}
–item 2 of working_list contains {3}
–item 3 of working_list contains {5}
–item 4 of working_list contains {7}
count working_list --indicates 3 groups of four will be processed
set the_new_item to {} --to contain the processed list
repeat with i from 1 to count working_list --counts 3 times, processing three groups of 4
set sub_working_list to item i of working_list --{1}, get first item in group of {{1}, {3}, {5}, {7}}
repeat with y from 1 to count sub_working_list --Repeat 4 times (four values in a set)
set the_item to item y of sub_working_list --the item = {1} on the first pass
repeat with x from 1 to the_item as integer --repeat as many times as the literal value: first pass=1 then 2nd=3, 3rd=5, 4rth=7
set the_new_item to the_new_item & x --build up the list
display dialog the_new_item as string --check the work
end repeat
end repeat
end repeat