Fork me on GitHub

@orlandomr27 Where is the reference to coming from? Is that part of your custom configuration? I see you have in your project.clj file?


Just for the record @seancorfield io.xapix/paos is now on Clojars so I deleted my .m2 folder, removed the :repositories tag from my project.clj and it’s fine now. 🙂


Searching for another solution I came to clj-soap. While a was playing with it I realize that is very easy to consume a SOAP service as a client, easier than paos. But there are no examples on how to send an array as parameters. I was using a version forked from your repo so I wonder if you have examples on how to do it.


@orlandomr27 I couldn’t get clj-soap to do anything useful (which is why it is archived). I ended up using wsdl2java, compiling the Java files and making a JAR, and then using that with clj-http as I recall. But it was years ago — and we no longer use that 2rd party service so we no longer have to deal with SOAP! Yay!


deal with SOAP it’s horrible, really. Well, I’ll stick to paos then which is working fine so far


Yes, I’,m using io.xapic/paos for a WSDL Service and they recommend to add enonic repository

Because soap-ws depends on a list of external dependencies that are not published in clojars or maven, you need to add them to the project's repository list yourself.


It worked until 3 days ago, no idea what happened

Erik B Good01:06:00

Hello, I was wondering how I could 'next' on a lazy cycle object and preserver lazyness. Let's say I have (cycle ["A" "B"]). I will get "A" if I call 'first'. I would like to get "B" the next time I would be calling first. Essentially (first (next (cycle ["A" "B"]))) And preserve the lazyness of my object. Thank you..


What you want isn't a functional programming behavior. You're asking for some mutation.


You should rethink what you are doing instead.


But if you really insist, this is a way to achieve something similar to what you are asking:

(defn mut-cycle
  (let [c (atom (cycle elements))]
      (ffirst (swap-vals! c rest)))))

(def foo (mut-cycle ["A" "B"]))
;;=> "A"
;;=> "B"
;;=> "A"
You cannot do what you want with sequences, because they force you into an immutable use. But you can achieve it with a mutable atom and a function closure like I did. Each time you call the function returned by mut-cycle you get the next element. You can call this infinite number of time, it will keep cycling.

Erik B Good12:06:12

yes I see what you mean @U0K064KQV I will think of another solution that behave in a pure way. Thank you for confirming what I thought


maybe a loop. (loop [thing (first my-cycle)] … (recur (rest my-cycle)))

Yang Xu03:06:13

Hello, I installed clojure via homebrew, and I add a new library in deps.edn that located in the clojure installed directory, and then I restart clj, but the library didn' download. Who can tell me which step I have mistake?


A first debugging step would be to ask clojure what’s in it’s classpath:

clojure -Spath

Yang Xu03:06:13

Nice skill, and it worked now, thank you.


👌 There’s also

clojure -Sdescribe
to check which edn files are loaded

Yang Xu03:06:38

Wow, how such helpful command, thank you again.


I am practising clojure and wrote below code

(def  map1 [ {:size 5 :color "blue" } {:size 7 :color "blue" }  {:color "Orange" :size 8} {:color "yellow" :size 10} ] )
(def  map2 [ {:size 7 :color "blue" } {:size 8 :color "Orange" }{:color "yellow" :size 10}  ])

(defn intersectionexample
  ([s1 s2]
   (if (> (count s2) (count s1))
     (recur s2 s1)
     (reduce (fn [acc item]
               (println s2 "-- " item "---")
               (if (contains? s2 item)
                   (update acc :match  conj item)
                   (disj s2 (set item)))
                   (update acc :non-match  conj item))

(println (intersectionexample (set map1) (set map2)))


This gave me clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative at (disj s2 (set item)) what am I doing wrong!!


You can check examples of how to call disj here:


You’re passing (set item) in second arg, however it expects one element per arguments, like this:

(disj #{1 2 3} 2 3 4)


This worked for me

(def st #{{:color "yellow", :size 10} {:size 8, :color "orange"}} )
(println (disj st {:size 7, :color "blue"} ))


but running in reduce is giving issue


You can use apply to call a function with the arguments from a collection:

(apply disj #{1 2 3} [1 3])


the error isn't with (disj s2 (set item)) , it's with (update acc :match conj item)


@U7RJTCH6J without disj line of code it is working fine


i added one more code disj


right, the value of acc is the value returned on the previous iteration. putting in the disj means that acc will be a set rather than a map for the next iteration. The first call to the reducing function should succeed and then error on the second call because of the disj


@U01J3DB39R6 as a general remark, this kind of code is not going to work as you expect:

                   (update acc :match  conj item)
                   (disj s2 (set item)))
The vast majority of clojure functions are immutable, so this update call is not going to modify acc, but return a new object, and the new object is immediately discarded as you don’t use it for anything


ok I agree, How can I update both acc and s2 ?


I do not want to use contains function from the beginning again of collection item


You’ll have to rethink your whole code. This is the challenge of learning functional programming. But in this case you don’t need to update s2 at all. You don’t want to call contains, but there’s actually nothing wrong with that


Here’s an excerpt from contains? doc string:

'contains?' operates constant or logarithmic time;
it will not perform a linear search for a value.


Since you’re using contains? on a set, the search time is not going to increase linearly with the size of the set


this will check wach element in one map with each element with the other right? this will n*n complexity


each contains? call is around~ constant time, so 1, then reduce is n, and… that’s it? so n total


or n log n, I don’t know how contains? exactly works with set


so u mean contains? call the thread?


there’s no thread here


What I mean is that contains? is not O(n)


i meant inner implementation of contains?


it’s O(1) or O(log n) per it’s docstring, when used on sets


so you mean how many records available in the both the map, contains work efficiently, right?


that’s the point of using a map or set, accessing a key is linear~ time


thanks @U7S5E44DB that helped

👌 2
Michael Stokley14:06:16

accessing a key in a hash map is linear time? or constant time


as the document says for contains, it says logarithmic or constant depends on the data

👍 2
Michael Stokley14:06:03

> that’s the point of using a map or set, accessing a key is linear~ time does the ~ post fix mean "better than"? @U7S5E44DB


it means "approximately", as it can be logarithmic time


I tried looking up the exact implementation of contains? for sets, but my java-fu is very bad and I didn't find it. Maybe it becomes logarithmic if the size of the set reaches a certain point

quan xing13:06:06

hello, everybody How can I insert the eval exp result into the end of the exp in emacs. I used C-c C-v C-f d is nothing happen

eric wolf17:06:58

hi quan, i tried running C-c C-v C-f d in the cider REPL and got a result in a buffer called cider-result i hope that helps. i've also found that C-c C-e also does an eval and puts the results in the message window.

eric wolf17:06:55

today i learned : if you add dependencies to a project and install bring them in them using lein deps you have to close the cider REPL and restart it (M-x cider-restart didn't seem to work for me) before cider will allow compilation.


to be pedantic: you don't install anything by using lein deps , all it does is check for their location in a cache, and load them into the cache if they are currently missing


lein isn't an installer, it's a build tool that manages a cache and uses declarative rules to decide which things in the cache a given process should use


this is done at startup, and that's why your repl needed to be restarted


also, really, "lein deps" should be considered an implementation detail of other tasks - anything you do which uses the project (start a repl, run the app, compile, build a jar) already does that deps task for you


There are ways to add new dependencies to a running REPL but they are not widely used right now. lein uses Pomegranate under the hood so you can require that in your REPL and load new libraries without a restart — see

💡 5

I use the Clojure CLI and deps.edn and a branch of org.clojure/tools.deps.alpha (via my dot-clojure repo files) and that branch — add-lib3 — has a way to load new dependencies into a deps.edn-based REPL (I use this quite a bit so I can keep my REPLs running for weeks).

💡 5
eric wolf17:06:55

Thanks for the clarification. In any case, just wanted to save others the headache of wondering what went wrong when the REPL complains. Also great resources, Sean.

Adam Krivka18:06:32

Is there a way to build a Clojure project to Clojure, i.e. just concat all the files to one (while resolving namespaces etc.)? Like e.g., tell shadow-cljs not to compile to JS/Java, but just give a one big main.cljs/clj file. 🙂

Adam Krivka19:06:44

I rewrote the original message, I hope it helps.


You could probably write a macro to accomplish this. You want to take all the qualified namespaces and expand them and weave it all into one gigantic main clj/s file? I mean it's doable, although I don't think much effort has been put into this particular direction currently.


i am practising clojure and I have a list as `

(def fruit ({:color "Orange" , :size 8} {:color "yellow", :size 10} {:size 7, :color "blue"}))
How can I add `
{:type "Fruit"}
each element of the list ?


that def makes no sense - surely that's [] or the literal is quoted


(map #(assoc % :type "Fruit") fruit) returns a new lazy-seq with :type "Fruit" added to each hash


Why `

(map assoc fruit :type "Fruit")
does not work and ?


map calls its first arg as a function, with the items of each other arg as args

user=> (map list [:a :b :c] [1 2 3])
((:a 1) (:b 2) (:c 3))


so the whole assoc, with all the args, needs to be inside a function that map can use


it might be helpful to note that map isn't a special syntax or operator (so it doesn't do magic argument packing / unpacking for readability), it's just a function that calls other functions on elements of collections

Mitul Shah19:06:43

super beginner here, is there an equivalent of a restProps in reagent? ex.

function Greeting({ name, ...restProps }) {
  return <div {...restProps}>Hi {name}!</div>;


@mitul (defn greeting [name & more] ...)


and then into usually being used to replace that interopolation right? never mind I read that wrong


more will be a sequence of all the additional arguments passed into the call of greeting. If you’re producing Hiccup output, you’ll need to use into or similar to “unroll” it.


Or [name & {:as props}] if you want a hash map there.


I thought the equivalent would look more like:

(defn greeting [{:keys [name] :as m}]
  [:div (dissoc m :name) (str "Hi " name "!")])

💯 2

although @seancorfield’s example is probably how I would write it

(defn greeting [name props]
  [:div props (str "Hi " name "!")])
;; usage
(greeting "Mitul" {:class "greeting"})

Mitul Shah19:06:17

yes this makes sense, thank you so much!

👍 2
Mitul Shah19:06:09

also interesting, props have to be in order when they’re passed through?

Mitul Shah19:06:43

because you didn’t define name="Mitul" , you just passed the actual string?


If you write the function this way. The other version, you would just pass a single map:

(greeting {:class "greeting" :name "Mitul" })


Separating the props and the name is just a matter of preference


☝️:skin-tone-2: That would probably be my preferred approach — using a name and an actual hash map rather than key/value pairs — although with Clojure 1.11 that’s less of an issue since you can now pass a hash map into a function that accepts “named arguments”.

🙌 2

I have 2 sets which has n number of maps, where I need to perform whether elements in one map is present in another map or not, this would be a time complexity of n*n , how efficiently I can do in clojure?


use clojure.set/index instead of just a bare set


how is this different from set/intersection? you don't need to compare every map to every map, you just need to check which maps are present in the other set (it will be most efficient if the smaller set is the first arg)


never mind, it's fast regardless of arg order

cmd)user=> (time (s/intersection #{{:a 0}} (into #{} (map (partial hash-map :a)) (range 10000))))
"Elapsed time: 5.630487 msecs"
#{{:a 0}}
(cmd)user=> (time (s/intersection (into #{} (map (partial hash-map :a)) (range 10000)) #{{:a 0}}))
"Elapsed time: 4.806462 msecs"
#{{:a 0}}


You could probably write a macro to accomplish this. You want to take all the qualified namespaces and expand them and weave it all into one gigantic main clj/s file? I mean it's doable, although I don't think much effort has been put into this particular direction currently.