swannodette / lt-cljs-tutorial

A ClojureScript Programming Language Tutorial for Light Table Users
MIT License
863 stars 123 forks source link

Weird #43

Closed jasonkuhrt closed 10 years ago

jasonkuhrt commented 10 years ago

I saw this today which looks wrong.

screen shot 2014-03-22 at 1 54 16 pm

Specifically, this part:

screen shot 2014-03-22 at 1 57 00 pm

Am I missing something or is this a bug?

jasonkuhrt commented 10 years ago

If it is a bug this issue belongs somewhere else, maybe light-table.

swannodette commented 10 years ago

@jasonkuhrt this is not a bug. Sets do not have an order.

jasonkuhrt commented 10 years ago

@swannodette How does first decide which element to take then?

I am able to produce what I would expect in another file:

(first #{:a :b :c}) ;; :a
(rest #{:a :b :c}) ;; (:c :b)

Are you saying this should be considered correct?:

(rest #{:a :b :c}) ;; (:a :c)

If so it seems to make rest etc pretty useless for sets?

jasonkuhrt commented 10 years ago

screen shot 2014-03-22 at 6 24 58 pm

I am still confused by these results.

My additions using the :a :b :c return what I expect. What's going on here?

15joeybloom commented 10 years ago

My guess is that sets are sorted by a hash value for its elements. Hash values are somewhat random by design, so that would explain the seemingly random ordering of the sets when they are coerced to a sequence.