Randomize a list in formula language

Wednesday, 23 February 2011 – 13:17

Today I was faced with a small problem – I needed to randomize a list in Lotus Domino formula language. After looking through the available commands I ended up with the following code;

REM {Original list that should be randomized};
_list := "A" : "B" : "C" : "D";

REM {Append random value to each element in list, then sort it};
_sortedlist := @Sort(@Transform(_list; "x"; @Text(@Random) + "|" + x));

REM {Extract the original value from element and return};
@Implode(@RightBack(_sortedlist; "|"); @NewLine)

The trick is to add a random value to each of the original elements and then sort the new list. After the sorting the random value can be removed.

Problem solved!

Sorry, comments for this entry are closed at this time.