Fork me on GitHub

Hi, I'm reading and I wonder what this "empty" commas at the end mean

(defn join [db main_table join_table join_col]
  (let [f #(let [x (-> db main_table %2)]
              (->> x
		   (get (db join_table) ,)
		   (merge x ,)
		   (assoc %1 %2 ,)))]
  (->> db
       (reduce f {} ,)
any hints ? never saw anything like this ...


Commas in clojure are whitespace, the reader ignores them


So they don't mean anything to clojure, but some people do that kind of thing to mark where threading macros will insert their arguments

👍 1

I don't much care for it


thanks, I understan now ....

Adrian Imanuel02:02:58

hi i tried to understand this in my doom-emacs, it'll prompt an input, but once i input it in my repl, it stuck, it doesn't return like that. how to do that in emacs?

(do (print "What's your name? ") 
What's your name? Clojure
i have to ctrl+c twice and result in error
Execution error (InterruptedException) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject/await (


emacs uses nrepl so things are a bit more complicated. when you attempt this, you'll notice in the bottom of your emacs window a prompt that looks like this:

Adrian Imanuel03:02:49

@U11BV7MTK I want to thank you from deepest of my soul!

😭 1

why you're quite welcome 🙂

Adrian Imanuel03:02:36

been looking for an answer since about 3 wks ago, now it comes to light. I'm so stupid


it makes sense to accept repl input from the repl. its kind of a quirk that it works this way. and the input request is tiny and out of site

Adrian Imanuel03:02:32

couldn't be more agree than this

Adrian Imanuel05:02:11

@U11EL3P9U thank you so much for helping me. it's because of i couldn't operate the emacs that well, but I got the concept of oauth2 because of you. still it's really simple, but I just found the answer today omg... lol :rolling_on_the_floor_laughing:.. again, thanks a lot!!


You're most welcome 🙂


Keep on 'learning! 🙂


emacs is wanting you to type there to send the input rather than in the repl buffer


are there clojure libraries for hmac?


thanks! I’ll try them out

Ryan Boldi08:02:45

Hey guys! I just started trying to use incanter to draw some plots, but whenever I do:

(ns main
  (:use [incanter core charts stats datasets]))
clj-kondo yells at me for using :use. Is there a succinct way to achieve the same thing using :refer :all? (p.s. it also underlines all my incanter functions like histogram due to unresolved symbol even though the code works)


@ryan.boldi123 clj-kondo yells at you because it has no way of knowing where some of the symbols in your code are coming from and therefore it discourages :use and :refer :all for that matter.


As a human I often have the same problem as clj-kondo, that's why I also don't use :use myself, I find that the code becomes more confusing. Just use :require + :as or :refer

Ryan Boldi08:02:36

@borkdudeSo would I need to always use fully qualified names whenever I call incanter functions? Something like incanter.core/view ?


@ryan.boldi123 No: (ns main (:require [incanter.core :refer [view]]))


Or: (ns main (:require [incanter.core :as i])) and then write (i/view ...)

Ryan Boldi08:02:09

@borkdude So I would need to write 4 require lines, one for core, charts stats and datasets?


yeah, well you don't have to, you can use nested libspecs, but that's another story ;)

😅 1
Ryan Boldi08:02:57

@borkdude Thank you very much!


(ns main (:require [incanter [core :refer [view]] [charts :refer [foo]]]))
This works, but this syntax has gone a bit out of fashion in favor of just writing the namespace names in full

😮 1
Ryan Boldi08:02:43

This is very helpful. I don't mind sticking to doing 4 separate requires for the sake of readability.


Does seq (and thereby keys and vals ) give some guarantee with respect to ordering for maps with identical keys ?


For example

(defn gen []
  (->> (for [i (range 1000)]
         [i (rand-int 1000)])
       (into {})))
does it always hold that
(= (keys (gen)) (keys (gen)))


no, it doesn't hold across different maps @finn.volkel


@ghadi so the guanrantee is not given, but the implementation always yields the same order or the implemenation does not always yield the same order?


If you add equal keys in same order to two maps the implementation today will have same order


If you add same keys in different orders to two maps, their order of seq, keys, and Vals can differ


thanks, that makes sense


Is there an appropriate way to 'pull in' functions from different namespaces into a namespace such that the symbols become accessible in that ns from other namespaces? That seems unclear... what I mean is to be able to do something like this:

(ns svg-clj.main
  (:require [clojure.string :as st]
            [svg-clj.utils :as utils]
            [svg-clj.specs :as specs]
            [svg-clj.transforms :as transforms :refer [translate rotate scale centroid bounds]]
            [svg-clj.path :as path]))

(some-kind-of-pull translate) ;; something to make the symbols accessible, incl. docstring and args
(some-kind-of-pull rotate) 
Then, a user would use svg-clj as follows:
(ns user.drawing
  (:require [svg-clj.main :refer [circle translate rotate]])) ;; user doesn't need to know about svg-clj.transforms


My guess: (intern *ns* 'translate translate), etc.


Hmm... tried that and it almost works. I do have the symbols accessible when :requiring main, but I don't see the argslist show up in my editor (my minibuffer in emacs usually shows the args as I type a fn)


@U01LR7M2B7A That's because the metadata is lost on that intern -- but you can get the metadata from the original var and add it to the new interned var. Something like this:


I'm using update to append the line about "Imported from..." but you could just do (insert *ns* 'translate (with-meta translate (meta #'translate))) I think. #' gets the var behind the function translate and you need that for the metadata.


I was just messing around with meta! Your linked code example gave me the hint I needed. I did not know about 'resolve' and was struggling to attach meta to the var as opposed to the symbol. Thanks for the help!

oly15:02:53 where can I put these ? I want to set a static path to resources/public so when i jack in I can ajax files tried in build.edn but either thats wrong or I am doing something else wrong 😕


is there a better way to write this?

(let [m {:foo "ab" :bar "cd"}
        bar (list (:bar m))
        foo (list (:foo m))]
    (concat bar foo))
=> ("cd" "ab")