This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-09
Channels
- # admin-announcements (3)
- # beginners (60)
- # boot (95)
- # braid-chat (2)
- # cider (12)
- # clara (1)
- # cljsrn (30)
- # clojars (2)
- # clojure (58)
- # clojure-art (1)
- # clojure-austin (3)
- # clojure-madison (11)
- # clojure-miami (6)
- # clojure-norway (3)
- # clojure-poland (13)
- # clojure-russia (67)
- # clojurescript (108)
- # core-matrix (39)
- # cursive (15)
- # data-science (6)
- # datomic (3)
- # hoplon (7)
- # jobs (9)
- # jobs-discuss (40)
- # ldnclj (5)
- # off-topic (6)
- # om (91)
- # proton (9)
- # re-frame (29)
- # reagent (7)
- # spacemacs (3)
- # testing (9)
- # yada (1)
@shaun-mahood: thanks
@virmundi: I like the immuconf approach to using edn myself
Is there a more idiomatic way to apply a function on every cell in a grid than this?: (map (fn [row] (map (fn [cell] (/ 1 cell)) row)) grid)
I’d probably write a fn so I could do (update-cells grid (partial / 1))
in neanderthal + fluokitten, it would be something like (fmap / grid), if grid is a matrix
@donaldball: interesting, is update-cells
a standard function? I can't find reference to it.
@bronsa: ah, that's true. That looks a little cleaner too.
No, just seems like a higher-order fn you’d probably want in your domain
sure, that's a good call too
you can write your own spy function that does that:
(defn spy [val func] (doto val #(println (func %))))
I guess in general I’m wondering how people deal with the fact that threading macros sort of discourage logging of the intermediate steps without a little extra work or refactoring them into a let
block
threading macro encourages the composition of pure functions so it’s a bit weird for logging to occur between those steps
I often write little helper functions like spy
during development.
Then remove them when I'm satisfied with the result.
IllegalArgumentException Don't know how to create ISeq from: java.lang.Integer clojure.lang.RT.seqFrom (RT.java:528)
(-> (range 10) (count) (first))
IllegalArgumentException Don't know how to create ISeq from: java.lang.Integer clojure.lang.RT.seqFrom (RT.java:528)
user=> (-> (range 10) (#spy/d count) (first))
IllegalArgumentException Don't know how to create ISeq from: java.lang.Integer clojure.lang.RT.seqFrom (RT.java:528)
user$eval20471.invoke(form-init4724596131896001508.clj:1) count =>
#object[clojure.core$count 0x688a74b "clojure.core$count@688a74b"]
user=> (-> #spy/d (range 10) (first))
user$eval20484.invoke(form-init4724596131896001508.clj:1) (range 10) => (0 1 2 3 4 5 6 7 8 9)
0
user=> (->> (range 10) #spy/d (filter even?) (last))
user$eval20519.invoke(form-init4724596131896001508.clj:1) (filter even?) =>
#object[clojure.core$filter$fn__4576 0x639ca7c8 "clojure.core$filter$fn__4576@639ca7c8"]
9
I think I’m over my head here. I guess I need to go read definitions of threading macros to understand if it’s even possible to make it work
I tend to just do (defn debug [x msg] (println msg x) x)
and then (-> (range 10) count (debug "count") first)
and have a debug-l
version with the args switched for use in ->>
expressions.
(->> (range 10) (filter even?) (debug-l "after filter even?") last)