Fork me on GitHub

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.


See also partition-by

👍 4

(for another take on splitting up data based on the results of applying a function)

Denis G11:12:18

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: 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)

Lennart Buit14:12:05

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?

Lennart Buit14:12:30

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?

Lennart Buit14:12:32

is that supported for datomic client?

Lennart Buit15:12:02

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))

👏 4

That Kafka example is perhaps more like

(defn infinitely-slow [] (Thread/sleep 10) (lazy-seq (concat nil (infinitely-slow))))
(take 3 (infinitely-slow))


is hashmap key order stable/guaranteed?


e.g. if i do

(for [[k v] {:key "val"}]


Yes, at least for a given object. Its order will match other things, like that produced by seq or vals


great, thanks!


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:


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. 🙂

👍 4

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


In general, what you are doing makes complete sense, IMHO.


Sometimes, putting an upper bound on the collection size being generated is a good pragmatic thing to consider.

👍 4

Thank you for your insight sir.

Andreas Edvardsson18:12:27

Is there a way to alias part of a namespace? i.e. alias a directory. Example: let's say the following namespaces exist: I'd like to get an alias for :as store say.


No, you can't do that. You can only alias the whole namespace name.

Andreas Edvardsson18:12:36

Okey great, now I know. Thanks Sean!

Lucas Barbosa19:12:52

Are the basic uninformed search algorithms (e.g. dfs, bfs, ucs) implemented in any core Clojure library?

Lennart Buit19:12:39

there is loom, for graph algorithms. Also, there is clojure.walk for navigating maps

Lucas Barbosa19:12:47

I'm going to take a look at loom, thanks!

Lennart Buit19:12:08

^^ happy holidays

aw_yeah 4

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?