brownplt / lambda-py

Other
58 stars 10 forks source link

set() is not removing duplicates #54

Closed amtriathlon closed 11 years ago

amtriathlon commented 11 years ago

for example:

print(set([1,2,1]))

gives

{1, 1, 2}

Found this while implementing dir(obj).

jpolitz commented 11 years ago

Hmm incremental adds work:

s = set() s = s.or({1}) s = s.or({1}) s = s.or({2}) s = s.or({1}) print(s) # {2, 1}

Maybe we should be desugaring to that, like dict() does to handle overlapping keys.

On Tue, Mar 26, 2013 at 12:46 PM, Alejandro Martinez < notifications@github.com> wrote:

for example:

print(set([1,2,1]))

gives

{1, 1, 2}

Found this while implementing dir(obj).

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/54 .

amtriathlon commented 11 years ago

Agree, that's a good idea, it is more general since it works with any iterable and it doesn't require set methods in other datatypes. I will do that.

2013/3/26 Joe Politz notifications@github.com

Hmm incremental adds work:

s = set() s = s.or({1}) s = s.or({1}) s = s.or({2}) s = s.or({1}) print(s) # {2, 1}

Maybe we should be desugaring to that, like dict() does to handle overlapping keys.

On Tue, Mar 26, 2013 at 12:46 PM, Alejandro Martinez < notifications@github.com> wrote:

for example:

print(set([1,2,1]))

gives

{1, 1, 2}

Found this while implementing dir(obj).

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/54> .

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/54#issuecomment-15471623 .

Alejandro.

amtriathlon commented 11 years ago

Fixed in https://github.com/brownplt/lambda-py/commit/c6b35977f1352a224c273bf77a250c317db91ecb