This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-12
Channels
- # beginners (2)
- # boot (1)
- # cider (3)
- # cljsrn (28)
- # clojure (70)
- # clojure-russia (1)
- # clojure-spec (21)
- # clojure-uk (2)
- # clojurescript (16)
- # component (10)
- # data-science (5)
- # datomic (9)
- # emacs (5)
- # fulcro (2)
- # jobs (1)
- # juxt (1)
- # klipse (23)
- # lumo (1)
- # mount (12)
- # off-topic (4)
- # parinfer (1)
- # re-frame (20)
- # ring-swagger (2)
- # spacemacs (4)
any suggestion for a good Clojure library for Twillio?
or I can just make the requests by hand otherwise
there seem to be a few but don't look too maintained/up-to-date
@plexus Has anyone tried using this union types module? https://github.com/lambdaisland/uniontypes I'm trying to use it with :dependencies [[org.clojure/clojure "1.9.0-alpha17"] [lambdaisland/uniontypes "0.2.0"] but keep getting an error that it can't find locate spec on my class path. But I can use spec from other namespaces in my project. I'm stuck.š
@plexus thanks, I'll try it. coming from F# / OCaml, I was really excited to see union types.
hi, im in my very beginnings of my clojure journey and i have a question. i have a set of sets containing values that i want to intersect, for two simple sets it is working, what i'm trying is: `(clojure.set/intersection (set [(set [1 2 3]) (set [3 4 5]) (set [5 6 7])])) ; not the expected result => #{#{7 6 5} #{4 3 5} #{1 3 2}} (clojure.set/intersection (set [1 2 3]) (set [3 4 5])) ;simple and expected result => #{3}`
you could use (apply intersection [set1 set2 set3]) and that will return a set with any element common to all 3 sets
(clojure.set/intersection (set [1 2 3]) (set [3 4 5]) (set [3 5 6 7])) -> #{3} (apply clojure.set/intersection [(set [1 2 3]) (set [3 4 5]) (set [3 5 6 7])]) -> #{3}
@derveloper is that what you are trying to do?
Yes, thanks!
Alternative solution is (reduce clojure.set/intersection foo)
where foo
is your set of sets.
can anyone explain to me why derive
requires keywords to be fully qualified ? it seems like a weird requirement ā furthermore, this requirement seems to go away when youāre using a custom hierarchy
@lmergen I believe it's ideological - since you're adding to the global hierarchy, enforcing qualified keywords avoids potential collisions. That's roughly how it's explained in Clojure Programming. I guess it is just an opinionated API, that's all.
Does it make sense to write code that leverages the fact that calling a promise delivers to it? a pro: makes my code simpler a con: most people that read my code probably don't know what it's doing
Whatās wrong with deliver
? From that snippet, the argument would be that itās clearly not idiomatic⦠but maybe it makes sense in the wider context of your code.
@chrisjd I was using #(deliver p %)
as a callback arg, and realized "oh, wait, I could just use p instead and get the same result"
though I guess one could argue for "if the callback is a promise, then the behavior of delivering to the promise is not surprising" - I don't know though
If it doesnāt leak too much of your implementation then you could just make the function accept a promise instead of a callback, yeah. Then the API is that some result gets delivered to the promise that you give it. That seems 100% reasonable to me.
well I don't need to change the function - calling a promise delivers to it
but I'll just use a lambda that calls deliver, people are less likely to be confused reading that
that's what my clojurebot snippet above was meant to show
Thereās a clojure project for using AWS Lambda I canāt remember the name of, it IIRC could take fns from the repl and upload them to lambda?
for some reason Iām remembering the name āportholeā but thatās not showing me anything
@lvh I vaguely remember someone talking about this in #clojure-uk not too long ago⦠I donāt think this is it, but looks quite good: https://github.com/uswitch/lambada
@noisesmith I think it is very similar situation as with sets and contains?
(#{:a :b} :a) ;; vs.
(contains? #{:a :b} :a)
@misha or hash maps or keywords for lookup
There's an obscure one :) doesn't work with atoms though
I'd try to keep code: 1) consistent across clj/cljs where it'd make sense 2) keep different tricks at minimum level. Just to make sure I am not surprised myself in 2 weeks reading it.
Yeah, I only discovered that feature of refs by accident, in a case that intuitively should have just been a "forgot to deref" bug
have not heard of it at all in 3 years, think it might be just an implementation side effect
Why else would ref support IFn and this be callable? Vars do the same thing.
Ref isn't doing the lookup, it's calling the object inside when called, just like a var.
on the other hand, I missed "nested reg-ex specs expect flat data structures" in spec guide after reading it like 7 times
Not sure, just saying implementation of a protocol isn't likely an accident it coincidence.
public final IFn fn() {
return (IFn)this.deref();
}
public Object call() {
return this.invoke();
}
public void run() {
this.invoke();
}
public Object invoke() {
return this.fn().invoke();
}
Refs and vars were older, maybe rh had second thoughts about the lookup and call pattern over time
That's what implimenting IFn looks like
I like that invoke trick and I'm going to steal it for my fixing-to lib
(implementation of invoke is a pain in the butt, there's ,20 arities to define)
Oh never mind, it still needs to define all the invoke arities
itās a special form
the source code for it is effectively in the Compiler: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L2686-L2825
most conditional macros ultimately bottom out on if
, but others of potential interest are things like when
, cond
, etc
Hi, is there a macro/special form that will allow me to conditionally evaluate some expression? If the condition fails the expression should disappear from the code. Something like this:
(into [] [1 (only-if true 2)]) ;; Expands to (into [] [1 2])
; => [1 2]
(into [] [1 (only-if false 2)]) ;; Expands to (into [] [1])
; => [1]