Fork me on GitHub
David Reno01:11:33

REPL driven development question… When I want to test a line in a function that depends on an argument without calling the function, what do you do to provide a value for the argument? Do you just throw in a ‘def’ or is there a better way?


I would do a let - doesn’t def create global scope?


What I often do is pull the line out of the function, and execute it in the repl, wrapped in a let


Doesn’t always work of course


@UBMFBEWKY Put a (comment ,,,) form immediately after the function. Then put (def addend 4) inside that comment and evaluate the def, then you can eval any form inside the function.

👍 3

That way you're not modifying the "production code", but your scratch code stays visible and available in your code for future use.


And maybe attend one of my online talks in December/January 🙂

David Reno02:11:35

Thanks! I know it’s a bit of a silly question but I figured there was a common way.

David Reno02:11:00

I like the (comment …) version.


"Rich Comment Form"


(because Rich Hickey does this too)


(and definitely not a "silly question" -- getting to a really efficient RDD workflow is something that a lot of people struggle with, because it's not like how you work with other languages)

👍 3

also, with code that exists already, it's often useful to insert a tap> call into the defn, then use an add-tap function that captures values for experimentation


this is my "stethascope" for examining internals of a running system with legacy code

David Reno20:11:16

I haven’t ventured into debugging running/deployed code. Tap is new to me, I’ll read about it. Maybe @U04V70XH6 will cover such wizardry in his upcoming talks? Thanks for the suggestion.


@UBMFBEWKY I will make sure I cover that (since I use Reveal alongside my editor to show all tap>'d values).

👏 3

How can fix the error:

clojure -M:uberjar
Compiling yubrshen.unique-errors ...

Compilation of yubrshen.unique-errors failed!

Could not locate yubrshen/unique_errors__init.class, yubrshen/unique_errors.clj or yubrshen/unique_errors.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I'm use an app template from: Here is the related alias for :uberjar:
:uberjar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.128"}}
            :main-opts ["-m" "hf.depstar.uberjar" "unique_errors.jar"
                        "-C" "-m" "yubrshen.unique-errors"]}
It seems that I may need somehow to install unique_errors.jar? Thanks!

Brian Chevalier06:11:06

What are the file/folder names used? It looks like a classpath error. Your namespace yubrshen.unique-errors includes a dash which is okay, but your filenames should uses underscores, replacing the dashes.


@brianbadahdah thanks for helping! yubrshen.unique-errors namespace is not of my own, it's prescribed by the alias of :uberjar, which is generated by clj-new template for app. My own namespace is just yubrshen.friendwall The error happened when I created the jar file for friendwall.jar (I don't even know the purpose of yurbrshen.unique-errors) Should I implement somehow <project-parant-folder>/friendwall/yubrshen/unique_errors.clj ?


Sorry, the error is caused by my mistake! unique_error was an old project of mine, that I forgot to change it to the new project frendwall, when I copy and paste the deps.edn

🎉 3
😄 3

Hello everyone, is there a way to get the query result without the brackets?

(d/q '[:find (pull ?e [:commit/rev])
         :in $ $date
         [?e :commit/date ?date]
         [(> ?date $date)]]
       @conn date)

;; => ([#:commit{:rev "25ed6cb"}]
;;     [#:commit{:rev "02a760a"}]
;;     [#:commit{:rev "61df934"}]
;;     [#:commit{:rev "d6524ab"}])
Like this but without the extra step.
(->> result
       (reduce (fn [acc e] (conj acc (first e))) '()))

;; => (#:commit{:rev "4e2cce7"}
       #:commit{:rev "13c57d1"}
       #:commit{:rev "8a3fd52"})

oxalorg (Mitesh)16:11:30

@lukas.block you can try doing this if it helps:

(map first result)
;; or
(->> result
     (map first))


hey thank you. The reduce was just an, I have to admit overly complicated example, for an extra step


I believe there’s a way to do it in the query without extra work afterwards


What is a good tool to ‘make 150 http requests (random order) with N workers’ ? Should I reach out to java.util.concurrent?


Going to do now with what I am familiar with .. java.util.concurrent.ExecutorService but I am interested in learning more about clojure.async which also seems to be able to do this

Ben Sless20:11:44

Client libraries like httpkit allow you to pass an optional thread pool (number of workers). You can then use core.async's async-pipeline to control the number of inflight requests


I need to investigate that. Right now I have a simpler approach:

(defn ping-endpoints [endpoints]
  (let [pool (Executors/newFixedThreadPool 8)
        tasks (for [url endpoints] #(ping-endpoint url))
        futures (.invokeAll pool tasks)]
    (for [f futures] (.get f))))

Ben Sless04:11:30

Beware that for is lazy. Laziness and side effects don't mix well together. I recommend either coercing it via doall or using mapv. Also take a look at


That looks very nice. I'll take a peek.


I wish I could just keep all data in memory and not bother with databases


You don't care if your data disappears when the power goes off?


I believe quite a few databases are good at keeping recently used data cached in RAM.


Sorry - what I mean is that I wish I could just Clojure data structures and not bother with SQL at all


If they would somehow magically persist to disk


Isn't this basically datomic?


Apparently the 4clojure server is down hmmm


Anyway, am doing qn 39 have a solution to make my own version of interleave but is there a way I can remove vector ? Like by changing concat to something else?

(defn leave [a b]
  (when (and (not-empty a) (not-empty b))
    (concat (vector (first a)) (vector (first b))
            (leave (rest a) (rest b)))))


I think you can use list* there


yeap list works too but was wondering if there's a concat that doesn't require elements to be in some form of collection


List* is that


Distinct from list. Often you’ll see lazy-seq cons cons leave


oooo! yeap it works


Also does anyone understand why mapcat vector works as a replacement for interleave ?


Okay nvm I got it, but I never knew that map applies the f to the first item of each coll then the second items and so on


yeah its a neat feature of map. other languages need a bespke map2, map3, etc