Domino Code Fragment

Code Name*
Sum a List of Values
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.145.60.166
Description*
Concept
Have you tried adding two list of numbers together? 1:1:1:1 + 1:1:1:1 = 2:2:2:2. Now lets split the resultant list and add the two list together. 2:2 + 2:2 = 4:4. Now do it again. 4 + 4 = 8. So if you start with the list 1:1:1:1:1:1:1:1 and use this process you would get your answer of 8. That's all there is to it. A little more to it. Obviously your list has to contain a number of elements equal to a power of 2. That's the first thing to fix. 1:1:1:1:1:1:1:1:1:1
1:1:1:1:1:1:1:1 1:1
1:1 1:1:1:1:1:1 1:1 1:1 + 1:1
2:2
Now concatenate the new list with the leftover list
2:2:1:1:1:1:1:1 Limits
There is a self imposed limit of 8192 elements that can be added together. The formula can be extended to add together millions of elements but there must always be a limit. 8192 was chosen for two reasons. 1: A number takes 8 bytes in LN. A lookup can only return 64k. Only 8192 numbers will fit into 64k. 2: A field on a form has the same limit. I've found that the fact of being a list also takes some of that 64k space and further limit the number of elements. Formula
Put the list in a field called values and pass it to the formula
Type*
Formula
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
list := 0;
adjust := 0;
elem := @Elements(values);
@If(elem = 1; @Return(values); elem > 8192;
@Do(@Prompt([OK]; "Error"; "Number of elements to add exceeded 8192"); @Return("")); "");
f := @Power(2; @Integer((@Log(elem) / @Log(2))));
@Set("adjust"; elem - f);
@If(adjust = 0; @Set("list"; values);
@Do(@Set("list"; ((@Subset(values; adjust) + @Subset(values; -adjust)) : @Subset(@Subset(values; f); adjust - f)))));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
@If(f > 1; @Do(@Set("f"; f / 2); @Set("list"; ((@Subset(list; f) + @Subset(list; -f))))); @Return(list));
list