This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-26
Channels
- # admin-announcements (4)
- # beginners (3)
- # boot (78)
- # cider (13)
- # cljs-dev (29)
- # cljs-edn (8)
- # cljsjs (11)
- # cljsrn (15)
- # clojure (81)
- # clojure-beijing (2)
- # clojure-belgium (3)
- # clojure-canada (1)
- # clojure-dusseldorf (8)
- # clojure-greece (6)
- # clojure-russia (40)
- # clojure-sg (1)
- # clojure-uk (59)
- # clojurebridge (1)
- # clojurescript (101)
- # core-logic (1)
- # cursive (3)
- # data-science (1)
- # datomic (60)
- # emacs (4)
- # error-message-catalog (12)
- # funcool (1)
- # hoplon (60)
- # jobs (1)
- # jobs-discuss (40)
- # leiningen (5)
- # liberator (1)
- # mount (22)
- # off-topic (8)
- # om (16)
- # onyx (53)
- # re-frame (11)
- # reagent (2)
- # specter (4)
- # testing (18)
- # untangled (51)
Is there a reason there’s no cond-let? (It seems like there used to be in contrib, but after contrib was deprecated, cond-let doesn’t seem to have ended up anywhere. This suggests to me that maybe people realized it was a bad idea for some reason.)
I can imagine if-let
and when-let
but what would cond-let
even look like?
Is it possible to have multimethods dispatch on a function of the dispatch-val and the val? The use case I am thinking of is dispatching to a multimethod when a object is an instance of a class. e.g.:
(defmulti my-method (fn [val dispatch-val]
(instance? dispath-val val)))
(defmethod my-method IPersistentVector
[val])
I have a question of aesthetics mostly. I made a state monad contraption and I want the binds to look ah.. nicer.
(defn move [thing location]
(>> (>>= (query [thing :location])
(fn [cur-location]
(guard (exists? cur-location)
(dispose cur-location thing))))
(acquire location thing)
(occupy thing location)))
;;Example code that doesn't look so nice.
(defn find-two-guys [guy1 guy2]
(>>= (query [guy1 :location])
(fn [loc1]
(>>= (query [guy2 :location])
(fn [loc2]
(return [loc1 loc2]))))))
Full source of the implementation is available here: https://gist.github.com/KGZM/2977192a27c5c28ae72c077a189e4c3bLispy prefix notation makes combinators a little weird and the nesting to get names from binds runs away fast. I like the combinators being variadic rather than binary.. but I'm wondering if there isn't a different way to think about this that might look a bit nicer.
@leov, it’s kind of a historical thing to sign libs. It’s done on Maven central and other places in Java land. In Clojars, there used to be two repos, one for anything people uploaded, and one for signed libs that matched the GPG key added to a users profile. That was too confusing, so there is only one repo now with no restrictions on signing or not. You could make a good argument that lein deploy :clojars
shouldn’t no longer try to sign libs by default.
In theory, we could build a Clojure web of trust, where we verify that every lib we use is signed by people we trust, and we can be sure we’re using the right code. In practice, I don’t think any of the Clojure tools verify this, so it may be security theatre? I’m not 100% sure on this yet.
@kgzm: You should check out mlet: http://funcool.github.io/cats/latest/api/cats.core.html#var-mlet
@risto: Hmm. That stuff is interesting. Thanks, gives me an idea for a macro that should clean things up and hopefully not cause too many problems.
euh, is it correct that i cannot define ad-hoc / lambda functions inside a threading macro? i'm getting errors about "first argument to rename-keys should be a vector"
can anyone guide me how to make a simple email client in clojure
can u suggest me any one
I am new to clojure
manalipankaj: check what you can find on http://www.clojure-toolbox.com
playing around with zippers, and parsing xml I found http://blog.korny.info/2014/03/08/xml-for-fun-and-profit.html
> (def myxml "<foo><bar>baz</bar></foo>")
;; => #'manntall-creator.core/myxml
> (def xzip (zip/xml-zip (xml/parse-str myxml) ))
;; => #'manntall-creator.core/xzip
> (xzip/xml-> xzip :foo)
;; => ()
ok, so, I'm trying to figure out the most elegant way to solve a problem. my problem: i need a conditional update-in, that only updates values when the keys are actually found. by default, update-in will create new entries if the keys are not found, which is not acceptable in my case. what is the best approach to this ?
@lmergen: I’d just try to get the value first, if absent, return the map, otherwise, apply the update
@slipset: how does that prevent update-in from calling when (:foo (fetch-val)) doesn't exist?
basically, I have an (update [xs])
function, which conditionally updates the database fields for an object.
one key is password
, which, if present, needs to be replaced with the hashed version. but if not present, shouldn't be in the result map.
@lmergen: is this what you want?
(defn update-in-if [m ks f & args]
(if (get-in m ks)
(apply (partial update-in m ks f) args)
m))
how do people manage these kind of functions in their projects, btw... do you just have a 'toolset.clj' file where you dump all these ?
The biggest PITA for releasing an open source package is Clojars, I've been using jitpack lately:
mpenet: yeah, i don't think the function works properly, since it calls update-in with all the keys, even if just a limited subset is actually available in the container
so i probably need to use select-keys to get the proper subset, and then call update-in
I could be wrong but I dont think that's mandatory (the pgp part). Even then it's a one time process for both.
Like I said, this is #C03RZGPG3 , we can move this discussion over there if you really want to argue about this, okay?
(.start (Thread.) function arg1 arg2) is the syntax, no?
or is it (.start (Thread. function arg1 arg2))
nvm, figured it out
(.start (Thread. #(function args*)))
You mean (defrecord ... (some-method [this] (assoc this ...))
? That's fine.
But don’t dissoc
the base fields out of a record — that turns the record into a regular map. Michal Marczyk mentioned that in his Clojure/West talk and I just lost a couple of hours this morning due to exactly that issue until I remembered that comment in his presentation!
When doing \
(defrecord ...)` clojure generates (clojure.core/defrecord)
. Is there a way to omit that clojure.core
namespace?
thanks @stuartsierra!