using for loop to find minimum values and saving results in a listI have three lists of numbers:
a= {2,3,4,5,6}
b = {4,5,7,2,1}
c= {9,6,4,6,2}
I would like to take the minimum of each index from the 3 lists and turn that into a list, say d. so d = {2,3,4,2,1}.
the loop i have started is:
minsl = {};
for(i = 1, i = 6, i++,
mins = {a[i], b[i], c[i]};
minval = minimum(mins);
minsl=insert into(minsl,minval,i);
If(n items(minsl)==5, break()); // this line was added to stop the loop because it gets stuck
);
the output is minsl = {1,1,1,1,1} i.e. is gets stuck storing the last entry in the list only (and foes on forever without the break line), when it should be {2,3,4,2,1}
Any suggestions how to fix?? Thanks!!
Automation and ScriptingRe: using for loop to find minimum values and saving results in a listHere is how I would approach the issue
names default to here(1);
a = {2, 3, 4, 5, 6};
b = {4, 5, 7, 2, 1};
c = {9, 6, 4, 6, 2};
a1= sortlist(a);
remove from(a1,3,n=length(a)-2);
b1= sortlist(b);
remove from(b1,3,n=length(b)-2);
c1= sortlist(c);
remove from(c1,3,n=length(c)-2);
d=a1||b1||c1;
Also, please use the icon at the top of the Preview window when entering script code. It allows for the reader to more easily read the code.