beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Endre Bakken Stovner 2021-06-11T05:12:24.060800Z

@manutter51 @noisesmith Thanks! I will test out your suggestions later today. It should also be said that I run the code that calls tap> in a Thread. which might add another layer of weirdness. Here is the whole function:

(defn read-process [proc type jobid] ;; babashka/process
  (with-open [rdr (io/reader (type proc))]
    (binding [*in* rdr]
      (loop []
        (let [line (read-line)]
          (when (not (nil? line))
            (tap> [jobid type line])
            (recur)))))))
Here is how it is called:
(.start (Thread. #(read-process bb-process :err jobid)))
(.start (Thread. #(read-process bb-process :out jobid)))

popeye 2021-06-11T06:06:31.063200Z

I am practising clojure program where I have 2 variable like below

(def  map1 [{:color "Orange" :size 8} {:color "blue" :size 9}] )
(def  map2 [{:size 8 :color "Orange" } {:color "yellow" :size 10} {:color "blue" :size 9}]) 
if any element of map 2 exist in map1 then store in some variable else store in other variable, I have checked with diff and compare did helped me, how can I write best program

dpsutton 2021-06-11T06:07:51.063500Z

(set/intersection (set map1) (set map2))

popeye 2021-06-11T06:12:26.063600Z

wow!!! how to get unmatched map ?

popeye 2021-06-11T06:16:04.063800Z

Also will this be a costly operation if we have n number of maps inside it?

Jacob Rosenzweig 2021-06-11T07:12:18.064700Z

What does @conn in this context:

(def cfg ...)
(def conn (d/connect cfg))
...
(some-function @conn)

Jacob Rosenzweig 2021-06-11T07:12:31.065Z

Does it reevaluate the var?

Jacob Rosenzweig 2021-06-11T07:13:09.065200Z

Oh it's a deref?

2021-06-14T15:21:47.141900Z

quote is often helpful - it reveals what the reader expands without evaluating:

user=> '@foo
(clojure.core/deref foo)

2021-06-14T15:22:41.142200Z

it even reveals itself 😄

user=> ''foo
(quote foo)

2021-06-14T15:23:02.142400Z

etc.

user=> '#(+ % %)
(fn* [p1__159#] (+ p1__159# p1__159#))

Jacob Rosenzweig 2021-06-14T17:10:37.142900Z

@noisesmith oh nice. I was doing (type foo) but this seems to tell me more.

2021-06-14T17:11:44.143100Z

it's not always useful, but it's easy to try and informative when it works

2021-06-14T17:12:13.143700Z

and learning why it works is a big step forward in deep understanding of clojure

Jonas-Daima 2021-06-11T07:49:25.067700Z

@ is a https://clojure.org/reference/reader#_deref for deref, so it is just that. As a side note, database connections are usually put in a delay, which requires deref. To ensure the connection is only created when explicitly asked for.

indy 2021-06-11T08:18:28.067900Z

(update {} :match conj item)
No parens around (conj item)

popeye 2021-06-11T08:21:19.068100Z

this also worked for me `

(assoc acc :match (conj (get acc :match ) item))

popeye 2021-06-11T08:22:07.068300Z

but agree to update

popeye 2021-06-11T11:40:51.070Z

I have a function, which is taking more than 3 minutes complete its operation due to huge data and it is expected, So I am planning to write it in multi threading application, any suggestion ?

indy 2021-06-11T11:47:38.071500Z

• What does the data look like? • What does the function do?

popeye 2021-06-11T11:49:10.071700Z

I have 2 map which each has more than 100000 map again, I am comparing with another map

indy 2021-06-11T11:57:04.075500Z

Don’t quite understand. You mean you have two vectors/lists/sets v1 and v2 which have 100000 hash-maps inside each? And you’re trying to compare v1[i] to v2[i]?

popeye 2021-06-11T11:57:17.075700Z

yes, checking element in one map is present in other or not

indy 2021-06-11T12:00:43.076Z

This can be parallelised, you can try pmap for a start. (pmap your-diff-fn v1 v2).