Fork me on GitHub
#clojure
<
2015-08-05
>
benbailey00:08:30

anyone have an idea as to why (apply name (keys (:exits loc))) doesn’t work if there’s multiple k/v pairs in (:exits loc)?

antishok00:08:24

@benbailey: because name takes only 1 argument. maybe you meant map instead of apply?

benbailey00:08:48

That’s it, thanks!

triss00:08:09

hey all. how does one go about configuring pprint such that it doesn't print symbol/record's namespaces?

triss00:08:55

how do I set *print-suppress-namespaces*?

pmooser00:08:50

@triss You can use "binding", like this:

pmooser00:08:02

If you're new, 'pp' is just an alias established like so: (require '[clojure.pprint :as pp])

triss00:08:34

hmmm... I'm getting: CompilerException java.lang.RuntimeException: Unable to resolve var: *print-suppress-namespaces* in this context, compiling:

benbailey02:08:05

so I have this code (:desc (state/get-room (:east exits))) that gets a description correctly

benbailey02:08:51

if exits is a hash-map of {:east :hallway, :north :conservatory}, what’s the best way to get the description of all of the rooms?

roberto02:08:59

hmmm, first thing that comes to mind is map

roberto02:08:19

(map :desc (state/get-room (:east exits)))

jeffmk02:08:46

@benbailey: If state/get-room return a map with :desc as a key, something like this should work (map :desc (map #(state/get-room (% exits)) (keys exits)))

jeffmk02:08:08

Can probably be done more cleanly.

benbailey02:08:02

ah, wasn’t sure map worked like that. Thanks!

cmdrdats06:08:16

I'm trying to figure out how to correctly control an async go loop (ie, shut it down when I'm done)

cmdrdats06:08:45

I have:

(def ca (async/chan 10))
(def a
  (async/go
    (loop [i 0]
      (println "Running")
      (async/>! ca i)
      (async/<! (async/timeout 2000))
      (recur (inc i)))))

cmdrdats06:08:48

how should I go about shutting down that loop? closing the go block channel sadly doesn't work 😕

cmdrdats07:08:27

Ah, got it. need to check that the >! returns true in order to recur.

(def ca (async/chan 10))
(def a
  (async/go
    (loop [i 0]
      (println "Running")
      (when (async/>! ca i)
        (async/<! (async/timeout 2000))
        (recur (inc i))))))

rickmoynihan09:08:07

I've got some protocols defined in a library with some default implementations of them in that library too, but in another namespace... Then my application requires the namespace, which results in the implementations being loaded.... Strangely when I run the application it seems that the implementations haven't been loaded, but if I nrepl in and re-evaluate the namespace that calls the protocol function it works... any idea what might be going on!?

rickmoynihan09:08:38

this stuff did work, and now its stopped - it's all very weird - running clojure 1.6

rickmoynihan09:08:30

actually it looks like its happening with two different protocols... one of them if I re-eval the calling namespace it fixes it... the other it doesn't and I have to re-evaluate the required namespace directly... bizzare

rickmoynihan09:08:21

ok really weird -- the problem disappears if I run it as an uberjar

rickmoynihan09:08:40

feels like a bug somewhere

rickmoynihan09:08:48

wondering if its related to checkouts in lein

rickmoynihan09:08:34

ok fixed it I'd changed version numbers in a checkouts folder and forgot to re run lein install

cddr22:08:44

That feeling when someone who uses def where a let should be is trying to tell you how to write clojure. I hate my life

arrdem22:08:42

so how many clojurians do you need to come tell this person they're wrong 😛

cddr22:08:45

Haha, I just need to vent and this is likely the only audience that understands

cddr22:08:23

Thinking of it as an opportunity to enhance my "people skills" simple_smile

redbeardymcgee22:08:28

Demonstrate a benefit.