Repeated function get pair

Hi guys,
I’m trying to make imperial function.

as IN there is a list,
as OUT there are two list

  • chosen pair of numbers
  • other numbers.

how can I put list of other numbers as IN again?

a = t4;
t2 = 6000 - a;
t5 = List.FirstItem(t2);
a1 = t4;
b = t5;
c = a1 - b;
t6 = c >= 0;
t7 = List.FilterByBoolMask(c, t6);
t8 = __TryGetValueFromNestedDictionaries(t7, “in”);
t9 = __TryGetValueFromNestedDictionaries(t7, “out”);
t10 = List.MinimumItem(t8);
t11 = IndexOf(c, t10);
x = t11;
t1 = {1, x};
t12 = List.RemoveItemAtIndex(t4, t1);
t13 = Flatten(t12);
t14 = List.GetItemAtIndex(t4, t1);
t15 = Flatten(t14);



t2 = 6000 - t4;
c = Math.Round(t4 - List.FirstItem(t2));
t6 = c > 0;
t7 = List.FilterByBoolMask(c, t6);
t8 = __TryGetValueFromNestedDictionaries(t7, “in”);
t10 = Math.Round(List.MinimumItem(t8));
t11 = IndexOf(c, t10);
t13 = Flatten(List.RemoveItemAtIndex(t4, t11));
t15 = Flatten(List.GetItemAtIndex(t4, {0, t11}));


What are you trying to do here? Not from a coding stance but from a ‘I want to use Dynamo to _____’ stance.

I assume you’re trying to turn this into an Imperative function to continue to use the list until a condition has been reached? What condition? Are you sure you need to do all that and not just use the list?

I have a list of numbers, I want to find best pairs from list that fit to 6000. probably yes, I need imperative. but so far I can’t find a way to make imperative for such complicated function.

Start making imperative code in smaller sections, working with the imperative and return first, then adding your functions into it.

Alternatively, you could leverage existing methods. There is a node for linear bin packing in the BIM4Sruct package which is designed to ‘get the indexes which best fill a given sum of values’, giving not necessarily pairs but utilizing the least amount of containers, so you may have a set of 3, 4, or n items.

thanks, BIM4struc really works. by the way, indexes given by their node are wrong