Proposing a new function for lists: Remove Duplicates
Currently I use a cumbersome way to create a list and then feed unique values to another list all for the purpose of removing duplicates. The USER_IDS is an integer list of record IDs. Because of the way my database is constructed, if the criteria is met, this list can have duplicates. To remove them, I have to feed the list of IDs to another list (UNIQUE_IDS) as long as the ID is not already there.
- USER_IDS = (DATABASE[(USER_DATA.contains(r.SUBLIST) && STATUS == "CONF")].ID).getall();
- for each n in USER_IDS
- {
- if(!UNIQUE_IDS.contains(n))
- {
- UNIQUE_IDS.add(n);
- }
- }
What I am proposing is a simple function that takes a list, and removes all duplicates:
- USER_IDS = (DATABASE[(USER_DATA.contains(r.SUBLIST) && STATUS == "CONF")].ID).getall();
- USER_IDS.removedups();
It should work for both string and integer lists.
John M. Whitney