This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Is there an equivalent of (juxt #(filter % %2) #(remove % %2))
in clojure.core
that does the work in one pass?
Please ignore. group-by
takes care of this for predicates that return a boolean.
(for another take on splitting up data based on the results of applying a function)
what is the common way of designing async api in Clojure. Callback based param? Returning channels like in CSP
@denisgrebennicov you can use pedestal
. You can return a channel in an interceptor
I don't understand lazy-seq
with take
, as in this example: https://techblog.roomkey.com/posts/clojure-kafka.html
My expectation is that take
will return everything available from the lazy-seq, up to the n
given. It's not doing that, it seems the lazy-seq is waiting for more data to fulfil the take.
(in my example, there are 8004697 messages - and I get exactly 8000000 of them, with a batch size of 10000)
Hey, I am starting to look into datomic, but I cant seem to find the agreed upon way to store and migrate the schema. Is there some form of library/convension of doing so?
In the non-datomic world, frameworks like rails and django have a table with migrations and a set of files in vcs, but that appears to be no convension in datomic is it?
is that supported for datomic client?
It appears to be not the case 😢
@danie It is possible to have an infinite lazy seq where elements take a while (block) in order to be returned, and take
will also block. For example:
(defn slow-seq [n] (Thread/sleep (* n 1000)) (lazy-seq (cons n (slow-seq (inc n)))))
(take 3 (slow-seq 1))
That Kafka example is perhaps more like
(defn infinitely-slow [] (Thread/sleep 10) (lazy-seq (concat nil (infinitely-slow))))
(take 3 (infinitely-slow))
Yes, at least for a given object. Its order will match other things, like that produced by seq
or vals
hm, any way I can reset all dependencies somehow? I'm using a docker clojure client, and at first, everything worked great, then I think the import of org.apache.commons.compress.archivers.tar
screwed something up, and I'm unable to recover. lein clean
doesn't help and everything works fine when creating a new project, but not in my existing one. Here is the error I'm getting + the snippet of code that works in one project but not the other: https://gist.github.com/victorb/e547e6fb02a6855500a4f308dea06da7
only thing that helped was explicitly putting [org.apache.commons/commons-compress "1.18"]
in my list of dependencies
(s/def ::a (s/with-gen (s/coll-of any?) #(s/gen (s/coll-of int?))))
::a
is a sequence of anything but for example generation and property based testing ints are used.
Does this make sense or is this an anti-pattern?
s
is clojure.spec.alpha
and gen
is clojure.spec.gen.alpha
@jaihindh.reddy It is certainly the case that generators often generate a subset of what is spec’d. But your example seems to go pretty far on that theme. 🙂
I get it. any?
and int?
are pretty far off 🙂
Is (s/coll-of any?)
good for generative testing though, because any?
value here are used as keys in a map, and it really doesn't (shouldn't) matter what type they are.
Testing with int?
is way faster.
Two points:
• any?
is not used above for keys in a map, but for elements in a collection
• Oftentimes generators are written in a way that is pragmatic wrt perf
Sometimes, putting an upper bound on the collection size being generated is a good pragmatic thing to consider.
Thank you for your insight sir.
Is there a way to alias part of a namespace? i.e. alias a directory. Example: let's say the following namespaces exist: example.store.user example.store.order example.store.etc... I'd like to get an alias for example.store :as store say.
No, you can't do that. You can only alias the whole namespace name.
Okey great, now I know. Thanks Sean!
Are the basic uninformed search algorithms (e.g. dfs, bfs, ucs) implemented in any core Clojure library?
there is loom, for graph algorithms. Also, there is clojure.walk
for navigating maps
I'm going to take a look at loom, thanks!
Also ubergraph, similar to loom -- I have not dug into both of those enough to tell the difference between them.
Loom implements graph algorithms based on abstractions (protocols). Ubergraph depends on loom, and is an implementation of Loom's protocols, a very flexible one at that. Loom itself gives you concrete graph representations but Ubergraph is more flexible (allows mixture of directed and undirected edges, multiple weights per edge, etc.)
How to add project local JAR into dependencies path with clj-new
generated deps.edn
?
@seancorfield HI, morning