This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-02
Channels
- # beginners (61)
- # boot (84)
- # cider (43)
- # cljsrn (2)
- # clojure (99)
- # clojure-android (3)
- # clojure-austin (2)
- # clojure-italy (5)
- # clojure-russia (43)
- # clojure-spec (93)
- # clojure-uk (41)
- # clojurescript (94)
- # clojutre (1)
- # cloverage (8)
- # core-async (31)
- # cursive (3)
- # datomic (14)
- # defnpodcast (1)
- # editors-rus (7)
- # events (1)
- # hoplon (15)
- # leiningen (3)
- # luminus (6)
- # om (142)
- # onyx (86)
- # other-languages (4)
- # pedestal (1)
- # planck (1)
- # portland-or (5)
- # re-frame (96)
- # reagent (16)
- # ring-swagger (17)
- # rum (73)
- # specter (25)
- # untangled (14)
- # yada (142)
morn'
måning
happiness this morning, when a random 4clojure solution from years ago came back and was useful
so, quick puzzle for the channel - how would you transpose a matrix (i.e. nested vectors) so that
(transpose [[:a :b :c][:d :e :f]]) => [[:a :d][:b :e][:c :f]])
(def transpose (partial apply map vector))
I remember I spent a whole day figuring out a recursive solution for transpose then saw that one-liner
I didn’t realize map
could take multiple sequences before I came across this problem. It’s such a useful feature, but hard to notice it’s there until you see it in use
One problem with map though is that it stops iterating once it's consumed the shortest list
I found an extend-tuple when browsing the clojure mailing list which also works for finite lists:
(defn extend-tuple
[default & colls]
(lazy-seq
(let [seqs (map seq colls)]
(when (some identity seqs)
(cons (map (fnil first default) seqs)
(apply extend-tuple default (map rest seqs)))))))
Nothing very complex - I was reading data from a spreadsheet that was in rows and I wanted it in columns
Ah - have been learning machine learning atm so my ears pricked up at the mention matrices
so…. I have a compojure app and it has an atom that holds the state (RESTful)…. how do I set the state of atom so that I can test various variations with clojure.test ?
(I have used midje previously, but that doesn’t seem to work with 1.9, so rewriting my tests to clojure.test)
@thomas you mean something more than reset!
?
unless i'm missing something, sure
what was the new thing @thomas ?