Hello,
I’m quite new in programming (at all levels). I’m trying to jump from nodes to DesignScript to improve some of my scripts.
I’m getting stuck with a simple for loop (I think, but my level it is what it is) and I don’t get how to get around this.
I’m trying to simplify this definition with for loop:
list1= [[“a”,“d”],[“b”,“e”],[“c”,“f”]];
list1[0];
nestedList1=[
(list1[0]<1>+list1[1]),
(list1[0]<1>+list1[2])
];
nestedList2=[
(list1[1]<1>+list1[2])
];
DSCore.List.Flatten([nestedList1,nestedList2]);
What I’m trying to do, it’s simplifying that code with a for loop, but there is something that maybe I’m not understanding in the way of getting the results from the for loop.
list1= [[“a”,“d”],[“b”,“e”],[“c”,“f”]];
iListCount = DSCore.List.Count(list1@L2) -1;
iList=iListCount-1;
[Imperative]
{
result = ;
for (i in 0…iList)
{
result = (list1[i]<1>) + (list1[i+1…iListCount]);
}
return = result;
};
When I finish this code I get an error: Imperative factor not valid.
I didn’t used the flatten here, because I couldn’t get further before getting the result in sublists.
Probably it’s a silly issue that I’m not considering or I haven’t understood correctly in the data list structure.
I hope someone can help me to get across this little rock.
Thank you in advance.