This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-23
Channels
- # announcements (10)
- # babashka (7)
- # beginners (31)
- # boot (4)
- # calva (8)
- # chlorine-clover (19)
- # cider (12)
- # clj-kondo (27)
- # cljsrn (7)
- # clojure (68)
- # clojure-colombia (2)
- # clojure-europe (47)
- # clojure-italy (16)
- # clojure-nl (4)
- # clojure-spec (13)
- # clojure-uk (39)
- # clojurescript (103)
- # code-reviews (8)
- # community-development (2)
- # conjure (38)
- # core-async (37)
- # cursive (2)
- # datascript (1)
- # datomic (31)
- # figwheel-main (22)
- # fulcro (18)
- # jobs (2)
- # jobs-discuss (6)
- # juxt (3)
- # keechma (1)
- # lambdaisland (6)
- # malli (30)
- # meander (20)
- # off-topic (29)
- # reagent (1)
- # reitit (16)
- # shadow-cljs (4)
- # tools-deps (70)
- # xtdb (19)
Hello, is there a function that can check if two values are equal but supports accretion? For example:
(is-equal {:first-name "David" :middle-name "Robert" :last-name "Jones"} {first-name "David" :last-name "Jones"})
;=> true
(is-equal {:first-name "Duncan" :last-name "Jones"} {first-name "David" :last-name "Jones"})
;=> false
I know that this isn't really equality, but I don't know how to express this. I'm writing tests and I want to perform assertions over the data that I pass to a function and I don't like having to correct tests just because my code now passes an extra key that isn't expected at all.what are the semantics? • true when :first-name and :last-name values match • true if the keys that do exist match • true if the overlapping keys have equal values • true if the keys of one map are a subset of the keys of another and the corresponding values are equal • something else?
(let [keys-i-care-about [:first-name :lastname]]
(= (select-keys keys-i-care-about
{:first-name "David" :middle-name "Robert" :last-name "Jones"})
(select-keys keys-i-care-about
{:first-name "David" :last-name "Jones"})))
;; => true
Yeah, definitely somthing like that. But I was wondering if there was already something more generalized.
I'm writing tests and all my tests have the form (is (= expected actual))
and I feel like =
is not really what I need here.
it probably depends on the use case, but based on the example, it seem like you want some sort of identifier
(= (:id first-map)
(:id second-map))
I've written a predicate I called submap? (Like subset?) For that kind of thing in the past
Not quite what you're looking for, but malli can be used to validate maps, and maps are "open by default" (you can ctrl-f that here: https://github.com/metosin/malli)
I think there's a submap?
in clojure.spec.alpha
but maybe it is private?
There's also a subset?
in clojure.set
, I think this works:
(defn is-equal [actual expected]
(clojure.set/subset? (set expected) (set actual)))
For tests in particular matcher-combinators are great https://github.com/nubank/matcher-combinators , and allow you to do a lot more stuff like checking if collections have the same contents but disregarding ordering
Thanks everyone for your input! matcher-combinators and motif have what I was looking for. 😁
If you know that a
has possibly more “stuff” in it than b
that you want to ignore, then couldn’t you also just do something like (= a (select-keys b (keys a))
?
of course. but take it to its logical conclusion of "open" / "accretion friendly" testing and you end up wanting some more things like those offered in some of the mentioned libraries.
@gabriel857 You might want to look at https://github.com/clojure-expectations/clojure-test/ which has a number of non-equality fancy "comparisons", including an in
(submap) test.
Hello , I'm new here, can anyone give any advice or online material for clojure interview questions?
there is also: https://building.nubank.com.br/nubank-acquires-cognitect/ https://building.nubank.com.br/welcoming-cognitect-nubank/
Nubank does not own Clojure, just as Cognitect never owned Clojure. Nubank will take over Cognitect's role as a corporate sponsor for Clojure, funding the core development effort
In what way?
for all that I like cognitect, compared to banks , dev consultancies are even more fragile.
also when people look at what lang to learn/use, allot of times who's backing it influences their decision.
I am a consultancy. The main problem is when 90% of you income comes from a single source. You become unfit, dependant and yes, fragile. Nubank deal sounds like they will now have 100%
That is a pretty glass half-empty way of looking at things. Are they more fragile than before? Is it unrecoverable from if things go wrong? I doubt it, I think it's great for them.
nice to see it when capital allocation works well and resources make it to the right people. congrats to cognitect! 🍾

My warmest most heartfelt congratulations to all the Cognitecters and their new colleagues at nubank! I wish you all the best, and I feel like this could be a great pivotal moment for clojure and the community; and it couldn’t happen to a more deserving bunch of people. I sincerely hope this is a career highlight for you all, and I’m sure your, indeed our collective futures will be all the brighter for it! My only question which is really a clarification, is does this: > Nubank does not own Clojure, just as Cognitect never owned Clojure. Nubank will take over Cognitect’s role as a corporate sponsor for Clojure, funding the core development effort; specifically mean that Rich has still retained all of the copyrights to clojure? I appreciate this is non of my business really; but as a longtime clojure practitioner it would be reassuring to know in concrete terms that Rich is still legally custodian of the language, beyond it being EPL licensed (which should be reassuring enough to be honest).
* Clojure
* Copyright (c) Rich Hickey. All rights reserved.
I thought rich has personally retained copyright even before cognitectand the Clojure Contributor Agreement specifically grants joint copyright to Rich Hickey
Great. Thanks a million for clarifying, that this hasn’t changed. And congratulations again! Please return to the much deserved celebrations! 😁 🎉 🎊 🎆 🍾 🍵
So Cognitect will be absorbed by Nubank, but they will continue to do Datomic consulting. Isn't it a bit weird for a bank to do database consulting? Or will Cognitect be a daughter company of some sorts, with their own brand still
"Cognitect will continue to operate as a U.S. C Corporation."
Congratulations regarding the acquisition! Hopefully this will turn out for better for all people behind Clojure and for us - its enthusiasts as well, fingers crossed!
It's great news and we're all excited to be part of Nubank!




@alexmiller congratulations to the Cognitect team - this is great news 🎉
I am particularly excited about the mentioned technical, social, and financial contributions. Anything to spread the goodness is welcome. Congrats to the Cognitect team!
Disclaimer: While I didn't work with Google's cloud storage - I use their SDKs with other APIs they offer. Based on that, I found that just using their Java SDKs was the best approach: you can adopt examples from their documentation, there's no extra layer between your code and the SDK and lastly, their Java APIs are ok and are not that hard to use from Clojure
I'm currently feeling that my namespace-fu is not well developed. Could anyone recommend a good introduction to namespaces, how local and external namespaces are managed, how that relates to the Java runtime environment, and what parts of the ns macro triggers these operations? Or some combination of that sort of documentation?
I'm puzzling over a profiling issue. I'm using Tufte to profile some code and I'm struggling to work out the discrepancy between the walk-clock time and the time taken in the profiled functions. The outer function times at 7.88s (and it does take about that long) but is just a loop that runs the inner function which times at 162us. Which is itself odd because this function is calling other functions that profile at ~1s clock time. Perhaps I am reading something wrong? Where is the missing 7s of wall-clock time?
it wouldn’t be the first time I would see very long GC pauses be the explanation for “missing time” in profilers
That is possible except 7s on a 1s runtime, I wouldn't expect to be creating that much garbage. I can't remember how to turn off the GC but I guess I could figure it out and re-run
I think your best course of action is to hook an actual java profiler into it and see what’s going on
Annoying, it seems like
:jvm-opts ["-XX:+UnlockExperimentalVMOptions" "-XX:+UseEpsilonGC"]
ought to do the trick but: Unrecognized VM option 'UseEpsilonGC'
Okay I wasn't able to disable the GC but I do seem to be able to log it's activity and it doesn't appear (assuming -verbose:gc
tells the whole picture) to be GC pauses
This would be in line with this code creating a fairly trivial amount of garbage for a 1000 tuple test.
i'm trying to communicate edn through a network. i'm sending edn to an aleph server and have tried different http clients. the problem is that these libs seem to know nothing about edn and I find myself converting edn to bytes and vice versa by hand. am i missing something?
http-clj works fine for me, I usually do it like ( -> (http-clj/get "url here") :body edn/read-string)
and am done with it.
For my current project I also put {:accept :edn}
in the "get" call, because server-side I use muuntaja which is a ring-middleware that converts the data according to the :accept
header the client sends
you might consider transit, which unlike edn is designed for communication between processes https://github.com/cognitect/transit-clj
Any idea what is going on here?
(defn test-2
[]
(loop [x? (pos? 1)
is (map some? [1 nil 2 nil])]
(when (not-empty is)
(recur
(first is)
(rest is)))))
Syntax error (IllegalArgumentException) compiling fn* at (env/cs/dev/ws_dev_dash.clj:175:1).
recur arg for primitive local: x_QMARK_ is not matching primitive, had: Object, needed: boolean