Fork me on GitHub

👋 I’m here! What’d I miss?

Ian Fernandez02:06:13

May I ask here questions about cljs?

Ian Fernandez02:06:21

I have some functions here, I dunno how to compose in a map like structure....

Ian Fernandez02:06:16

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 ?

Ian Fernandez03:06:38

I want to iterate send-image-to-contact! onto the contacts vector

Ian Fernandez03:06:17

and the send-image-to-contacts! is not working


does clojure have association lists like common lisp does?


@radicalmatt Clojure has first class associative data structures: hash maps.

Jim Newton08:06:56

is there a standard clojure documentation system which I should use if I'd like to release a library to the public?


@U010VP3UY9X will use the docstrings from your function definitions, eg. (defn name "docstring explaining the function" [] (algoritym)) . Also README and CHANGELOG files.

Jim Newton07:06:07

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?

Jim Newton07:06:04

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]})
{:s "a"
 :t [1 2 5 6]
 :l [3 4 7 8]}

Daniel Tan13:06:50

looks like a reduce concat keys


Thanks for the replay, I played around with those functions a little but still no luck

Daniel Tan14:06:14

@rickheere (apply merge-with (comp flatten vector) a)

Daniel Tan14:06:29

quite interesting

Daniel Tan14:06:04

(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]}))

  (apply merge-with (comp flatten vector) a))

Daniel Tan14:06:11

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

Daniel Tan14:06:28

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


and yes (apply merge-with (comp vec concat) a) also work, probably better.


Thanks everyone.


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

👍 4

@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


the test of a collection being sorted does not require sorting it to be sure


Yea, thats true and finding out it's not sorted is probably faster than sorting it.


wow how did I miss apply


sean strikes again


I would probably do something like this to verify if not sorted, then resume

 (fn [acc v]
   (if (<= acc v)
     (reduced false)))


hm I didn't know about reduced either


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 helpful for that (as long as the 3rd party libs are all Clojure).