# List combination, Cartesian

**URL:** <https://forum.dynamobim.com/t/list-combination-cartesian/7527>\
**Category:** Lists-Logic\
**Created:** [November 15, 2016, 1:20pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527 "2016-11-15T13:20:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 15, 2016, 1:20pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/1 "2016-11-15T13:20:22Z")

</div>

Hello All,

I can not find the right nodes for what I would like to do.

Let’s assume I have 2 different lists, each of them contains 3 parameters. I would like to combine them as below:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/6/c/6cacfa7fa96a402887f3d5f37db577e59d566bf8.png) ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/3/b/3bc4e79759c081d3bc49bb7ebe4d38db53615746.PNG)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [November 15, 2016, 1:29pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/2 "2016-11-15T13:29:28Z")

</div>

This is going to largely depend on your datatypes. Laymens answers assuming you really are dealing with stings is to concatenate using cross product lacing (each item of listA gets matched with all items of listB):

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/7/2766e8043565dc3fc0d569fdd67043f3c29ac217.jpg)

Example using lines:

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/7/770900166ea113b6285b05bc7f16b6e7fb8a7593.jpg)

---

<div class="post-metadata">

**Author:** ![Alisder\_Brown](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alisder_brown/32/14995_2.png) [@Alisder\_Brown](https://forum.dynamobim.com/u/Alisder_Brown)\
**Post date:** [November 15, 2016, 1:36pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/3 "2016-11-15T13:36:08Z")

</div>

Another option  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/7/b/7b0fd0ffd9de51b2f6a09695ba987ed9c43e0e6a.PNG)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [November 15, 2016, 1:43pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/4 "2016-11-15T13:43:25Z")

</div>

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/3/b3a634b53e12a7f4ffdc6399f75c4454252383a4.png)

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 15, 2016, 1:46pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/5 "2016-11-15T13:46:14Z")

</div>

Thanks @Thomas_Mahon & @Alisder_Brown & @Kulkul

How will it be if I would have more lists; like 4? The result should show 81

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/c/1/c1271c34500257277073fc774d0e0f6db0f3ec1f.png)

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 15, 2016, 1:55pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/6 "2016-11-15T13:55:37Z")

</div>

I just followed the code block that @Kulkul wrote. But I am sure I did not do it correctly

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/4/b4e1b605e6a7dda5490d13379e146b632e9123a0.png)

---

<div class="post-metadata">

**Author:** ![Alisder\_Brown](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alisder_brown/32/14995_2.png) [@Alisder\_Brown](https://forum.dynamobim.com/u/Alisder_Brown)\
**Post date:** [November 15, 2016, 2:09pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/7 "2016-11-15T14:09:21Z")

</div>

What is the output would you want with 4 lists?

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 15, 2016, 2:12pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/8 "2016-11-15T14:12:38Z")

</div>

@Alisder_Brown

3 \* 3 \* 3\* 3 = 81

full combination of each list with others

---

<div class="post-metadata">

**Author:** ![Alisder\_Brown](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alisder_brown/32/14995_2.png) [@Alisder\_Brown](https://forum.dynamobim.com/u/Alisder_Brown)\
**Post date:** [November 15, 2016, 2:26pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/9 "2016-11-15T14:26:19Z")

</div>

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/8/a/8aaa8e2d1c207adf4e811833e0f44a3266b9058e.PNG)

As above?

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [November 15, 2016, 2:45pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/10 "2016-11-15T14:45:03Z")

</div>

@Raha_R Following the logic of your initial post, your math is incorrect since you don’t combine the first list with itself, meaning it should be 3 x 3 + 3 x 3 + 3 x 3:

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/c/ccdc285b1781d3a424ce8defb940f32fb19226ca.jpg)

```
listA;
otherLists;

t = [Imperative]
{
	concatList = {};
	for (i in GetKeys(listA)) //iterate through the input list
	{
		concatList[i] = {};
		for (j in GetKeys(otherLists) ) //Iterate through matching lists
		{
			for (a in GetKeys(otherLists[j]) )//Iterate through the members of the other lists
			{
				concatList[i] = List.AddItemToEnd(listA[i] + otherLists[j][a], concatList[i]);
			}
		}
	}
	return = concatList;
};
```

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 15, 2016, 3:15pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/11 "2016-11-15T15:15:05Z")

</div>

@Alisder_Brown Thanks so much! I think it’s exactly what I want.

@Thomas_Mahon you are right, in the case I really want to do full combination… but in my case, the “af” and “fa” doesn’t make difference because I will replace the strings with numbers that defined as the dimension of object…

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [November 15, 2016, 3:18pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/12 "2016-11-15T15:18:25Z")

</div>

@Thomas_Mahon solution at its best 👍. The imperative block.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [November 16, 2016, 3:01am UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/13 "2016-11-16T03:01:39Z")

</div>

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c86afe10cd75b08eed37dc64cf4db89f69a93e17.png)

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 16, 2016, 5:22pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/14 "2016-11-16T17:22:55Z")

</div>

Thank you all.

Now my question may seem stupid but I wonder how to do the same combination when the list contains numbers…  
the + math may not work in this case? because it adds up the list numbers before combining

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/d/7da4a97d9a33b66acd6dd58b8f09a699e70237ff.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [November 16, 2016, 5:37pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/15 "2016-11-16T17:37:07Z")

</div>

Convert them to strings then back to numbers again if that’s important.

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 16, 2016, 6:17pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/16 "2016-11-16T18:17:34Z")

</div>

@Thomas_Mahon Thank you. Yes it’s important because I want to feed them as parameter’s value.

how can I create a bunch of numbers as a list in each row? for example having list of numbers in each row…  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/7/77448c1b55843f5b03dd34b4b8ac7f56d5ace137.png)

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 16, 2016, 6:22pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/17 "2016-11-16T18:22:39Z")

</div>

I also tried to separate them first and then combine, but again I don’t know the problem why they are not combined correctly.  
Is there anyway to increase lacing or something like that?

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/a/faa21e318cfa426bbb70ea1a7ae861a490cefa42.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [November 16, 2016, 8:06pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/18 "2016-11-16T20:06:01Z")

</div>

You’re kind of contradicting yourself with those images. Can you be clearer? Maybe just type precisely what you expect to see and what list structure you expect to see.

---

<div class="post-metadata">

**Author:** ![Raha\_R](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Raha\_R](https://forum.dynamobim.com/u/Raha_R)\
**Post date:** [November 16, 2016, 10:39pm UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/19 "2016-11-16T22:39:41Z")

</div>

@Thomas_Mahon Sure. I hope these explanations make it clearer what I am looking for:

I have 4 different parametric objects (like the cylinder, cube, etc). one parameter from each one is desired to be changed. For example; I want to change the height of each one.  
I also defined 4 different lists (for each parameter), which contain 3 numbers as the ranges that are supposed to be fed into parameters value.

What I am going to do is automatically generate the changes while covering the possible combinations from the first list to the other lists (I don’t need to combine the first list with itself). the results I am expecting is  
3x3x3x3.  
I want to feed these combined values into the loop and change all of the heights simultaneously (so as a result; I will see objects with different heights in each loop.)

“Now my problem is to combine the lists like how I need, then use it as parameter value…”

I hope my detailed explanation doesn’t bring up more ambiguity.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [November 17, 2016, 3:16am UTC](https://forum.dynamobim.com/t/list-combination-cartesian/7527/20 "2016-11-17T03:16:24Z")

</div>

@Raha_R If I’ve understood your intent, what you need is very straightforward

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/d/5de9e7863a739bcbb04ef62cbb62d5a9838099c6.png)
