Author: bugman Date: Wed Apr 17 23:01:45 2013 New Revision: 19489 URL: http://svn.gna.org/viewcvs/relax?rev=19489&view=rev Log: Created the lib.list.unique_elements() function for returning a list with duplicates removed. Modified: trunk/lib/list.py Modified: trunk/lib/list.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/list.py?rev=19489&r1=19488&r2=19489&view=diff ============================================================================== --- trunk/lib/list.py (original) +++ trunk/lib/list.py Wed Apr 17 23:01:45 2013 @@ -26,10 +26,26 @@ def count_unique_elements(values=None): """Count the number of unique instances in the given list. - @keyword values: The list of values to count. + @keyword values: The original list. @type values: list @return: The number of unique instances. @rtype: int + """ + + # Create a new list. + new_list = unique_elements(values=values) + + # The number. + return len(new_list) + + +def unique_elements(values=None): + """Return a new list with duplicates removed. + + @keyword values: The original list. + @type values: list + @return: The new list with duplicates removed. + @rtype: list """ # Create a new list. @@ -38,5 +54,5 @@ if i not in new_list: new_list.append(i) - # The number. - return len(new_list) + # Return the new list. + return new_list