How can I combine multiple lists(has some boolean in it) into one list

Hello,I‘m test some more complex scripts,I found myself stuck at this,I make a simple one to demostrate my problem.here’s screenshot and the dyn file.

combine mutiple lists.dyn (38.7 KB)

If I get any help,I would appreciate it.

1 Like

@mavs013 ,

you can play with this


KR
Andreas

Thank you for your reply,I want to know how to combine two list(with false boolean) into one,your answer is is kind of like replacebycondition node,I’ve tried successfully using String.Concat node,but it’s not very smart way to combine two list into one.


combine two lists.dyn (39.0 KB)

what is your expected result?

What I want is combine multiple lists(which have false value in it)into one list.
I have done it by the node String.Concat but I don’t think it’s a good way.
combine mutiple lists.dyn (38.7 KB)

Hello, a possibility in this way


code block:

List_A;
List_B;
K=DSCore.List.Count(List_A);
rep=[];
[Imperative]
{
for (i in 0..K-1)
	{
	if (List_A[i]==false)
		{
		rep[i]=List_B[i];
		}
	else
		{
		rep[i]=List_A[i];
		}
	}
return rep;
};

Cordially
christian.stan

1 Like

Thank you very much,it works!!
But I also wonder what if there has more than two lists?

?

1 Like

by adding ifs but Mr. Vijay’s solution is more efficient, we must dig in this direction, I think

Cordially
christian.stan

Thank you ,actually I tried “remove if not” node,it doesn’t generate the result I want,I should explain my proble more accurate.It’s like this,the value actually should stay at their index.
combine mutiple lists.dyn (49.4 KB)

Mr. Vijay track

Cordially
christian.stan

2 Likes

Thank you,I should understand list more.

1 Like

I think the solution comes more from Mr. Vijay’s analysis than mine

cordially
christian.stan