This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-30
Channels
- # aws (1)
- # bangalore-clj (2)
- # beginners (64)
- # boot (29)
- # cider (4)
- # clara (14)
- # cljsjs (22)
- # cljsrn (24)
- # clojure (248)
- # clojure-austin (5)
- # clojure-berlin (1)
- # clojure-china (5)
- # clojure-france (1)
- # clojure-greece (1)
- # clojure-italy (2)
- # clojure-korea (6)
- # clojure-russia (76)
- # clojure-spec (2)
- # clojure-uk (59)
- # clojurescript (67)
- # cursive (12)
- # datascript (6)
- # datomic (126)
- # defnpodcast (2)
- # devcards (1)
- # docker (1)
- # events (2)
- # hoplon (14)
- # leiningen (1)
- # luminus (2)
- # midje (2)
- # mount (1)
- # off-topic (4)
- # om (6)
- # onyx (8)
- # parinfer (2)
- # perun (6)
- # proton (5)
- # re-frame (41)
- # reagent (6)
- # ring-swagger (3)
- # rum (1)
- # spacemacs (10)
- # specter (12)
- # yada (25)
if i have a value a
, that is either a string or a vector, and i want to conjoin that into vector b
, what would be my best approach ?
i was thinking a combination of conj
and flatten
, but i suspect there is a single function that could handle this
@seancorfield no more comments on my code ?
I have this json file :
{"levels":[{"name":"z3","width":1771,"height":1441,"tiles":[{"x":2,"y":1,"url":""},{"x":1,"y":1,"url":""},{"x":3,"y":2,"url":""},{"x":2,"y":0,"url":"
now im looking for the entry which name is equal to z4 . Within the entry Im looking for the tile's part.
@roelofw I'm not going to be at my "big" computer until at least Sunday -- I'm off to Clojure/conj tomorrow! 🙂
@seancorfield no problem. Maybe then I have the last part ready. Getting the image-url of a painting
@roelofw
something like this?
(let [[z4] (filter #(= (:name %) "z4") (:levels json))] (:tiles z4))
I was just typing something like that 🙂
@seancorfield much fun on the Clojure/conj
Why does this code never comes to a end :
(defn read-image_url
"Reads the image-url"
[id-list]
(pmap (fn [id]
(let [art-objects (-> (str " " id "/tiles?key=14OGzuak&format=json" )
(client/get {:as :json} )
:levels
)
url (filter #(= (:name %) "z4"))
tiles (:tiles url)
]
{:id id :tiles tiles} )) id-list))
(read-image_url ["SK-C-5"])
you probably want the :body
part of the response object and filter
returns a seq so you want to destruct the first element
trying to figure out a nice way to represent a fixed set of keywords as a kind of enum type
like i have a bunch of error reasons -- :missing :bad-request :server-error, whatever
that i want to match against-- but it seems like i'd just have to know the keyword names in every location
@olslash I'd just use a set of the keywords and then use that set as a function when matching
trying to define a bunch of error handlers that handle the same types of thing -- and in my head i was thinking i wanted the safety of something like a protocol which says like "Can't define method not in interface" if you mess up
How do I get the :tiles
part out of this : ({:name z4, :width 885, :height 720, :tiles [{:x 0,
^^ @roelofw yeah you have a map inside a sequence so first you need to get the map from the sequence then extract the :title
from the map
so this one : ({:id SK-C-5, :tiles [{:x 0, :y 1, :url .... })
and this one ({:id SK-C-5, :description Het korporaalschap van kapitein Frans Banninck Cocq en luitenant Willem van Ruytenburch, bekend als de 'Nachtwacht'. ]})
get merged
oke, I can use assoc but it looks I have to pull the part I want to update out of the big {}
Has anyone ever done a benchmark of the clojure.core.match
performance? How much is it better than, say, a cond
?
it depends on the data structure you use inside match
, i.e. vector vs seq vs map vs list vs ...
but of course, “it depends” :)
Hi all. When implementing a protocol with defrecord, how do I setup local bindings? I tried:
(defrecord Engine [canvas]
(let [a 12]
IEngine ;
(init! [this] (log (str "initializing engine with a = " a)))
(start [this] (log (str "starting engine with a = “ a)))
(stop [this] (log "stopping engine"))))
but, of course, an error.@gamecubate you can't share a binding across multiple protocol methods