This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-01
Channels
- # 100-days-of-code (2)
- # announcements (3)
- # beginners (95)
- # bitcoin (1)
- # cider (18)
- # cljdoc (9)
- # cljs-dev (8)
- # clojure (55)
- # clojure-austin (1)
- # clojure-berlin (4)
- # clojure-italy (21)
- # clojure-nl (1)
- # clojure-russia (2)
- # clojure-spec (47)
- # clojure-uk (31)
- # clojurescript (19)
- # component (8)
- # cursive (5)
- # data-science (2)
- # datomic (33)
- # emacs (7)
- # events (1)
- # figwheel (8)
- # fulcro (16)
- # graphql (27)
- # hyperfiddle (5)
- # jobs (1)
- # jobs-discuss (85)
- # keechma (7)
- # luminus (11)
- # mount (6)
- # off-topic (23)
- # onyx (1)
- # re-frame (4)
- # shadow-cljs (29)
- # specter (19)
- # tools-deps (11)
- # uncomplicate (3)
The author may not have ever created a ticket in Clojure's JIRA tracker. Even if they did, that is no guarantee a suggested enhancement is even considered.
Probably just fell off the radar, if it was ever on the radar.
This brings to mind RBBs again, and why it might be preferable to have data structures with fairly consistent performance across operations, even though they’re not faster in each individual case. https://github.com/clojure/core.rrb-vector
@crankyadmin (take 10 (cycle [1 2 3 4 5]))
Hello, I've found this:
user=> (pr-str {:user/aaa 1})
"#:user{:aaa 1}"
user=> (pr-str {:a 1 :user/aaa 1})
"{:a 1, :user/aaa 1}"
Is this some kind of bug?> Maps will be printed in namespaced map form only when: > All map keys are keywords or symbols > All map keys are namespaced > All map keys have the same namespace
actually it's also on https://clojure.org/reference/reader
makes me wonder: why not doing the same for sets: #:foo#{:a :b :c}
(edit: actually it's mentioned in the jira)
is there a function like the #:ns macro? - Something like (ns-map {:db/id 25 :attr 8} :myns.entity)
#:myns.entity{:db/id :attr 8}
Can someone recommend a way to reload a Clojure (server / backend) application when a source file changes?
I'm currently doing it through the REPL with clojure.tools.namespace.repl/refresh
, but maybe there is some more common way.
@andreas862 (reduce (fn [a [k v]] (assoc a (if-not (namespace k) (keyword "myns.entity" (name k)) k) v)) {} {:ccc 321 :aa 123})
Thank you
If you build new Clojure backend service from scratch, consider using https://github.com/duct-framework/duct a lot of handy stuff a la carte.
:thumbsup:
I am having trouble generating "recursive" data structures defined with clojure.spec.alpha
. I found the issue https://dev.clojure.org/jira/browse/CLJ-1978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#issue-tabs where I also posted this, but I'm not quite sure if that was the right place or if I should open a new issue for this.
The first example in the original post works fine for me as well.
This seems to have something to do with the s/spec
call, since without that I can create such recursive maps just fine and with very high depth.
Am I doing something wrong here? And if not, should I maybe open a new issue for this?
In SQL Korma, does (create-db config)
have a "delete" counterpart that I can use to destroy the connection pool?
In addition, I do not see how I can define entities (tables) if the database connection is not yet available, e.g. because I will create it dynamically later.
Hi there I have a programmatic issue that you guys maybe could help with: I have a sequence of maps
{:key "foo", :version 1}, {:key "foo" :version 2}, {:key "foo" :version 3}, {:key "bar" :version 1}, {:key "bar" version 2}
and I would like to reduce this to all unique maps with the highest versions. In the example the correct result would be
{:key "foo" :version 3}{:key "bar" version 2}
My problem is that I cannot find a function that takes a collection and removes duplicates (depending on a predicate that i specify). The only such function I know of in clojure is set
, but this just compares by value. In my example, it would be necessary to first sort by :version
and then remove duplicates by :key
.
In haskell I did something like
let sorted = sortBy (\x y -> _version y `compare` _version x) maps
nubBy (\x y -> _key x == _key y) sorted
hope someone that knows can help1If your version is going to be a number then you could use
(apply max-key :version coll)
where coll
is your sequence of mapsthat would give you the highest version but maybe not exactly what you need
@lsund You could write a variant on the distinct
core transducer function (call it distinct-by
) that takes a predicate. See (source distinct)
for more info on how to do it, but it shouldn't be too bad
distinct-by
is a fairly common util function that is added to many libs, so there’s quite a bit of reference code 🙂 https://crossclj.info/clojure/distinct-by.html