# HG changeset patch # User bengioy@grenat.iro.umontreal.ca # Date 1209494080 14400 # Node ID 718befdc867137209e968542e70490c4dcb2f5a7 # Parent b6730f9a336d3c07c8f7be7b5774b3014fd1f349 Miscellaneous general-purpose functions diff -r b6730f9a336d -r 718befdc8671 misc.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc.py Tue Apr 29 14:34:40 2008 -0400 @@ -0,0 +1,8 @@ + +def unique_elements_list_intersection(list1,list2): + """ + Return the unique elements that are in both list1 and list2 + (repeated elements in listi will not be duplicated in the result). + This should run in O(n1+n2) where n1=|list1|, n2=|list2|. + """ + return list(set.intersection(set(list1),set(list2)))