Fork me on GitHub
#clojure
<
2016-06-12
>
bcbradley02:06:42

Can I use a set as a key in a map and expect the correct results?

hiredman02:06:57

the answer is a little more nuanced outside of the core clojure data types, and kind of depends what you mean by correct results, but yes

hiredman02:06:17

the core clojure stuff has value identity, so it combined in all number of ways stuff works great as map keys

hiredman02:06:47

if you go out in to java land, and have a clojure set of mutable LinkedLists, that will work less well

bcbradley02:06:15

({#{:crunchy :savory :salty} "frito-lays" #{:crunchy :savory} "celery} #{:crunchy :savory :salty})

bcbradley02:06:18

what would that yield

hiredman02:06:35

what you expect

bcbradley02:06:44

"frito-lays" is what i expect

hiredman02:06:54

run it in a repl

bcbradley02:06:12

i'm trying to map from "intentions" to "things that happen"

bcbradley02:06:22

but really, I want to map from sets of intentions

bcbradley02:06:29

i'm happy that clojure is smart enough to let me do that

bcbradley02:06:18

how long have you been with clojure hiredman?

hiredman02:06:21

I must have first started doing project euler problems in clojure sometime in 2009

hiredman02:06:27

I was employed as a clojure programmer from early 2010 to late 2015, and have been unemployed looking for a job since

genmeblog12:06:09

question... how to force expanded macro to keep type hints?

genmeblog12:06:15

I have macro which create function, this function expect java class a parameter, and to avoid reflection I need type hint

genmeblog12:06:33

I don't want to call (vary-meta) or (with-meta) before using variable each time

magnus17:06:55

How can I make the following macro print “ABC” instead of the symbol abc? (defmacro foo [abc#] (println abc#)) (def abc "ABC") (foo abc)

magnus17:06:17

Ignore, I understand what I did wrong.

genmeblog22:06:25

let me rephrase issue I raised a couple of hours ago: how to keep type hint which is under syntax quote untouched and not interpreted? Just treat it literally? I want to have: `(fn [^java.util.Random r] (.nextInt r)) -> (clojure.core/fn [^java.util.Random user/r] (.nextInt user/r))

genmeblog22:06:19

I found this discussion around the topic, but I'm not sure if it addresses exactly my issue. https://groups.google.com/d/topic/clojure-dev/KTkQCj-TJx8/discussion

gfredericks23:06:19

gowder: enlive can definitely parse strings