On 23/01/2006 18:41, Mathijs uttered:

>> len([ref.pop(ref.index(x)) for x in lis if x in ref])

> This is the type of solution I was hoping to see: one-liners, with no
> use of local variables. As Tim Chase already wrote, it has only one
> less elegant side: it alters the original ref list.
> 
> Thanks for your suggestion.

May I suggest another one-liner:

 len(set(ref).intersection(lis))

I have no idea how this scales/performs compared to the other
suggestions you've received, but I find it immediately comprehensible.


-- Morten
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to