Fork me on GitHub

How can I conj into the last element of a vector? e.g (conj-in-last [1 2 [3] 4]) => [1 2 [3 4]]


It’s probably easiest to pop it off, conj it with your value and then conj it back on.


Something like (let [new-val (conj (peek my-vec) my-val))] (conj (pop my-vec) new-val) (Not tested, on phone)


just tested in the reply, works a beauty, thanks again @UA8TV3QHF


No worries 🙂


If it's constant size, you can destructure it.

(let [[a b [c] d] [1 2 [3] 4]]
  [a b [c d]])


The size grows but the last element is always the one being updated


Hi! Is a way to work with the latest version of Google Closure Library in ClojureScript ? The version that is shipped with cljs is two years old 😕


You may want to ask in #clojurescript channel to see if someone knows there.


Hi all! When I launch a clojure script is there some way (other than (System/exit n) to close the process with a non-zero exit code?


@manuelrascioni what's the issue with System/exit?


I'm launching a script using the maven-exec-plugin, if I do System/exit it shutdown the entire maven build 🙂


I would like to just stop it


ah, I have no idea about maven-exec-plugin but probably there is a hook/function you can call to exit from whatever wrapper you're inside


@manuelrascioni one work around could be throwing an exception which would cause it to stop as its uncaught.


Also as far as i know, the exec:exec forks the java process so System/exit should be okay. What you could be using is the exec:java goal which runs in the same JVM hence kills the entire thing. Correct me if im wrong though


Hi @U7ERLH6JX, you're totally right. Looking around the internet I found that using the exec:exec goal is the only way to fork process so that I can use System/exit but giving the easiness of using the exec:java I opted for throwing the exception (and having it's rubbish in console)

😄 5

Are there any good linters for clojure in emacs? I normally use flycheck for linting in emacs, but I see that Clojure isn't on the list over supported languages


Thanks for that 🙂

👍 5

Neat, I got eastwood and kibit working from cli, but I can't seem to get squiggly-clojure working by following their readme instructions. I don't get any linting in emacs when I open cider and load the file.


I had better luck going with joker for clojure linting in emacs. Get it installed and on your path (e.g. /usr/local/bin/joker) and then you can use flycheck-joker:


not really a clojure question but more a design one. i made a web app in Clojure that might be used in different languages and i was thinking of doing localization. My idea was to have edn (config) file that would be slurped during startup and then used inside components say like this config

{:usd {:placeholder "hello"
      :title "Hi"}
 :ita {:placeholder "bongiorno"
       :title "ciao"}
and then used like [:input {:placeholder (:placeholder @localization)}] or something like that how do you approach your way of localizing apps?


That would be the general idea but you can look at i18n libraries for this eg.


thank you very much for suggestions! i didnt know about these


If I want to add a license notice at the top of my file do I just use a bunch of ;;s or do I use the comment function?

Alex Miller (Clojure team)16:02:00

comment is code and the license string must be read and compiled into bytecode, which takes compile time, load time, and memory


I don't think it ever reaches bytecode :)

Alex Miller (Clojure team)16:02:59

oh, it’s a macro, I guess that would make sense


Still I would also recommend ; since then whatever is in such comments can be arbitrary sequences of characters, without any risk of upsetting the Clojure reader, it need not have balanced parens, brackets, etc.


I'm getting started coding on clojurescript and, coming from the js world, I'm used to setting breakpoints and stepping through the code in order to debug. I've tried a similar approach with cljs sourcemaps and the experience seems to be hit and miss (not all breakpoints are hit and the stepping through the code usually takes me to core js files that are minified and obfuscated). Is there a better alternative? I've tried using the repl but still unfamiliar how I could inspect some of the objects (say an atom inside a let clause) even though I can access globally declared atoms for that namespace. Any tips would help, really enjoying the language so far but the tooling makes me want to go back to js world at times.


if you’re OK trying out some alpha software, I’ve been working on a tool for inspecting data in a better way than just println or console.log:


let me check this out. thanks for the quick reply!


@jorda0mega punk looks nice. I haven't discovered it yet. What I use all the time is the debux library: With debux I don't miss step-by-step-debugging. debux works like a trace tool but can be inserted inside of expressions and has the powerful dbgn macro that traces every part of a (complex) expression in a very readable way.


@jorda0mega using the REPL + printing I think is what the majority of CLJ(S) developers do. CLJS debugging is not super well supported, you’re right


however, writing your functions that work well at a REPL helps enforce good practice structuring your code

👍 5

@lilactown Does ClojureScript support tab> in the latest version? I've found that's very helpful for debugging in Clojure.


it does support tap> yes 🙂


that's what my experimental REBL-like tool uses:


Hah! I should have followed your link. That's very nice!


give it a whirl and let me know what you think! 😄


I don't do any cljs stuff at all. Good to know punk is out there in case I ever start using cljs again 🙂 I use REBL all the time with clj!

Lennart Buit21:02:48

What is you guys preferred way to find performance problems. I can use criterion to time code that is slow, but it doesn’t tell me why. I tried VisualVM, but that appears to not want to play nice with cursive’s REPL


It’s been a long while since I’ve used Cursive, but doesn’t it have some built-in profiling? I could easily be misremembering.

Lennart Buit21:02:35

(VisualVM appears to be quite unstable~ish on MacOS, often not updating)

JIacheng Yang22:02:50

Why is this a memoized fibonacci calculation? It seems to me that an atom of empty map is created every time memoize is called and not passed around


@yjc961020 (def fib (memoize fib)) is a one-time call that binds the result of calling (memoize fib) -- which returns a function -- to the symbol fib, and the subsequent calls to fib call that (returned) function, they do not call memoize again.

JIacheng Yang22:02:08

oh, i see so there is only one atom which serves as the cache for values?


If you said (defn fib2 [n] ((memoize fib) n)) then you would be calling memoize with each call to fib2.


(def fib1 (memoize fib))
(def fib2 (memoize fib))
(def fib3 (memoize fib))
now you have three separate atoms, one for each call to memoize.


But each of fib1, fib2, and fib3 can be called separately (they are three different functions, each with their own cache). So (fib1 35) will be slow on the first call and fast on the second (and subsequent ones). If you then call (fib3 35) it will also be slow on that first call and then fast on the second etc.

JIacheng Yang23:02:01

Yes, it is much clearer to me now. Thanks