This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-31
Channels
- # adventofcode (1)
- # beginners (24)
- # boot (10)
- # cider (3)
- # cljsrn (11)
- # clojure (83)
- # clojure-dev (8)
- # clojure-russia (1)
- # clojure-spec (6)
- # clojure-uk (3)
- # clojurescript (25)
- # cursive (6)
- # datomic (7)
- # docs (1)
- # emacs (5)
- # hoplon (14)
- # jobs (1)
- # luminus (1)
- # off-topic (13)
- # om (3)
- # onyx (10)
- # parinfer (3)
- # re-frame (1)
- # ring-swagger (1)
- # sql (1)
- # unrepl (62)
How do you use any assets file that is provided by cljsjs package? I'm using leiningen.
@noisesmith I’d appreciate any help with maintaining liberator. I try to fix bugs and merge sensible improvements where I can, but my time is very limited. You’re welcome in #liberator to discuss what you’e missing.
I have
(defn get-owner [db paper-id]
let [query-string "SELECT user_id FROM papers WHERE paper_id=?"]
(get (first (query db [query-string paper-id])) :user_id)
)
and it is telling me I cannot take the value of a macro. I have moved it around in the file so I don't think it is something outside that. What am I doing wrong?that let
should be in parens
(let [ ... ] ... )
Thank you, it is amazing what you cannot see sometimes.
What is the best way to write a function which will take a sequence like [[filter-fiction? true] [filter-hardback? false] [etc etc]]
and produce a predicate fn which can be used to filter a sequence like [{:title foo :fiction? true :hardback? true} {etc}]
such that if filter-fiction?
is true, then only items where :fiction?
is true will be returned.
I’m very new to clojure and to programming in general and can only come up with horribly messy solutions to this…
@noob a good first step would be to put that sequence into a hash-map, so you get easy lookup of each property
So it would look like {:filter-fiction? true ...}
? I’m not sure how that helps, I know I want to loop through each filter, and if its true add it to the predicate fn that I pass to (filter pred coll)
but I’m not sure how to do that in a clojury way…
in that case I'd imagine a combination of filter (to get the predicates), map (to get the right thing for each predicate) and every?
to form the predicate
also symbols is a weird choice there, more typical would be keywords or strings - keywords are not just for keys in maps, they are for when you want something that unambiguously only stands for itself
I meant filter-fiction?
I assumed foo was something bound to a string
Ok I’m still stuck… I want to write something like this (I know this isn’t syntactically correct)
(defn filter-books
[filters books]
(when (:fiction-filter? filters)
books = (filter (:fiction? %) books))
(when (:hardback-filter? filters)
books = (filter (:hardback? %) books)))
but I know that won’t work in a functional language… I guess I don’t understand how to use map
in this context..@alex395 you can create new bindings by using let, and those bindings can refer to other previous bindings or shadow them (reuse the same name)
+user=> (let [filters []
filters (if (even? 3)
filters
(conj filters :odd-input))
filters (if (> 3 10)
filters
(conj filters :small-input))]
filters)
[:odd-input :small-input]
Ah I didn’t realise you could do that! Thanks for the help I think I’ve got it now 🙂
So pomegranate somehow allows me to not have to restart cider/my repl. But its not clear how im supposed to add it to my ~/.lien/profile.clj as what exactly? A library? A plugin? Once this is setup correctly, i’m i supposed to do something special beyond adding libraries like normal in my project.clj? Do i need to run something like this example from the readme:
=> (use '[cemerick.pomegranate :only (add-dependencies)])
nil
=> (add-dependencies :coordinates '[[incanter "1.2.3"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" ""}))
;...add-dependencies returns full dependency graph...
=> (require '(incanter core stats charts))
nil
it's a library, you can add it as a normal dep