This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-13
Channels
- # babashka (5)
- # beginners (52)
- # biff (11)
- # brompton (5)
- # calva (2)
- # cider (7)
- # clojure (80)
- # clojure-europe (3)
- # clojure-finland (1)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-uk (3)
- # clojurescript (15)
- # conjure (4)
- # core-async (9)
- # cursive (3)
- # datahike (38)
- # datascript (1)
- # datomic (7)
- # duct (9)
- # emacs (4)
- # fulcro (11)
- # graalvm (21)
- # honeysql (5)
- # lambdaisland (1)
- # leiningen (1)
- # news-and-articles (1)
- # off-topic (8)
- # react (42)
- # reagent (6)
- # reitit (11)
- # shadow-cljs (62)
- # specter (1)
- # spire (2)
- # sql (1)
- # tools-deps (12)
- # vim (5)
May I ask here questions about cljs?
I have some functions here, I dunno how to compose in a map like structure....
I want to send-image-to-contacts!
to work, some tip ?
@d.ian.b I'm not entirely clear what you're trying to do, but I suspect that #core-async might be a good place to ask, or #clojurescript ?
thanks!
I want to iterate send-image-to-contact!
onto the contacts vector
on main
and the send-image-to-contacts!
is not working
@radicalmatt Clojure has first class associative data structures: hash maps.
is there a standard clojure documentation system which I should use if I'd like to release a library to the public?
@U010VP3UY9X http://cljdoc.org will use the docstrings from your function definitions, eg. (defn name "docstring explaining the function" [] (algoritym))
. Also README and CHANGELOG files.
https://github.com/cljdoc/cljdoc/blob/master/doc/userguide/for-library-authors.adoc
I don't understand about the CHANGELOG. Am I responsible for physically updating the file, or is it something that happens automatically according to certain reserved words in git commit messages? or do I need to create git tags for important commits?
I'm using my schools local installation of gitlab which has an issue tracker. Is there a way for me to make issues and associate their fixes with certain commits, and have the changelog assembled from that information?
A changelog is usually update manually, and adding links to the most relevant issues or pull requests to include. You may find tools that help with creating a changelog, but I see the changelog as a summary of activities. All the details are in the issue tracker, commits and pr's, so the changelog helps humans understand if something important to them has changed.
How do I transform this?:
({:s "a"
:t [1 2]
:l [3 4]}
{:t [5 6]
:l [7 8]})
to:
{:s "a"
:t [1 2 5 6]
:l [3 4 7 8]}
looks like a reduce concat keys
Thanks for the replay, I played around with those functions a little but still no luck
@rickheere (apply merge-with (comp flatten vector) a)
quite interesting
(apply merge-with vector a)
{:s "a", :t [[1 2] [5 6]], :l [[3 4] [7 8]]}
(apply merge-with concat a)
Ah, very good. {:s "a", :t (1 2 5 6), :l (3 4 7 8)}
is what I get from
(def a '({:s "a"
:t [1 2]
:l [3 4]}
{:t [5 6]
:l [7 8]}))
(comment
(apply merge-with (comp flatten vector) a))
(apply merge-with concat a)
+1
I think that is good enough for now. Thanks @delaguardo and @danieltanfh95!
If you care about list versus vector in the result, you can replace concat
with your own hand-written function that checks for list vs. vector, etc.
(apply merge-with (comp vec concat) a)
works as well
I managed to get it to work with this as well
(apply merge-with (fn
[a b]
(into [] (concat a b))) a)
Does anyone have an idiomatic way to test if a vector is sorted? I've got a predicate using destructuring and recur and I don't like it very much.
depending on the size you could just do (= c (sort c))
where c is your vector or collection
@radicalmatt If all the items in the vector are numbers, I guess you could also try (apply <= c)
?
@dpsutton That was my first thought too, but, then you can just sort the vector and know that it's sorted, saving an equals on the whole vec
If the true / false test of a <= b is some other function cmp, then something like (every? (map cmp (partition 2 1 coll))) would work
If it comes from outside your application I would say you have to sort it yourself to be sure. If it's your own code, maybe it's possible to write some static analysis?
Not at a repl to test that right now — it is probably at least slightly wrong
I would probably do something like this to verify if not sorted, then resume
(reduce
(fn [acc v]
(if (<= acc v)
v
(reduced false)))
a)
What’s a good approach for printing the stack frames of a function call in Clojure? I would like to see the entire stack trace including the 3rd party libraries that my function is calling.
@tkjone At any given point you can try & catch an exception and get the stack elements from the exception object: there's a function Throwable->map
in Clojure that will turn the object into Clojure data.
But you can only get at the stack from where you are in the call tree -- you wouldn't able to see down into 3rd party code below your current execution point.
Thanks, Sean! So the only way to trace, for example, a 3rd party library, I would have to clone said library and run the trace through that library. In general, i’m researching how a library works and I want to see all the function calls being made to get a high level overview of the code paths.
Thanks! I will give this a try 🙂
kind of like of you can do this with console.trace
in cljs/js
@tkjone You may find https://github.com/clojure/tools.trace/ helpful for that (as long as the 3rd party libs are all Clojure).