I don't know if there is a better way of doing this.. Thought I'd throw it out here and see what comments I got.
Someone on Notes.net wanted to know which item in a list was repeated the most.
They specified that they wanted to use formula language..
So I wrote the following:
list := "dog" : "cat" : "dog" : "mice" : "rat" : "dog" : "dog" :"dog" : "dog" : "dog" : "dog" :"dog" : "dog" : "dog" : "dog" :"dog" : "dog";list1 := @Unique(list);temp := 0;temp1 := "";@For(n := 1;n <= @Elements(list1);n := n + 1; @For(z := 1;z <= @Elements(list);z := z + 1; @If(list1[n] = list[z];temp := temp + 1;temp) ); temp1 := @Trim(temp1 : (list1[n] + "~" + @Text(temp))); temp := 0 );temp2 := @Sort(temp1;[CustomSort];@If(@TextToNumber(@Word($A;"~";2)) < @TextToNumber(@Word($B;"~";2));-1;@TextToNumber(@Word($A;"~";2)) > @TextToNumber(@Word($B;"~";2));1;0));@Prompt([OkCancelList] : [NoSort];"temp2";"temp2";"";temp2);MostInlist := @Subset(temp2;-1);@Prompt([Ok];"How Many";"There are " + @Word(mostinlist;"~";2) + " " + @Word(mostinlist;"~";1))
basically, I used two @for loops..
Then I sorted my results so that the most was at the bottom of the list, then I grabbed that last element and parsed out the last value..
Anyway.. any other bright ideas using formula and not lotus script.
The times, they are a-changin....
17 hours ago
