Fork me on GitHub

Hi all, Created a file named scripts/migration.clj: It starts like: (ns sindu.migration ... (`sindu` is the name of root folder.) Create a main function inside the file.

(defn -main []
  (println "sindu.migration/main"))
Created a deps.edn at root:
 {enlive {:mvn/version "1.1.6"}
  ragtime {:mvn/version "0.8.0"}
  org.clojure/java.jdbc {:mvn/version "0.7.9"}
  mysql/mysql-connector-java {:mvn/version "8.0.15"}}
 :paths ["src" "resources" "scripts"]}
Then tried calling main function of scripts/migration.clj: clj -m sindu.migration I get errors:
Exception in thread "main" Could not locate sindu/migration__init.class, sindu/migration.clj or sindu/migration.cljc on classpath.
	at clojure.lang.RT.load(
	at clojure.lang.RT.load(
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.main$main_opt.invokeStatic(main.clj:491)
	at clojure.main$main_opt.invoke(main.clj:487)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(
	at clojure.lang.Var.applyTo(
	at clojure.main.main(
What am I doing wrong?

Alex Miller (Clojure team)11:04:47

File should be at scripts/sindu/migration.clj to match the ns

👍 4

@UC1DTFY1G hey, are you dumrat on the Project Euler forums? Nice to see you here! One of the only other Clojurians on there.

😀 4

@UGHNF0CS3 Do you do Project Euler as well?


Yes, since February, but after solving about 90 problems, it’s getting too hard to remain enjoyable 😅 most recently I solved #437 and that took me a week (studying time, optimization, etc)

😮 4

I did the first 92, and got stuck with 93 and sort of gave up. Never really got into the harder ones I guess.


But I found that I generally enjoyed solving the problems in Clojure more


Hi I'm new with honeysql I have a function that supposes to return all the states where client-id equals with c-id and their counter are between from and to my function is attached. but I get class cast exception:: java.lang.Long to Clojure.lang.IFn any suggestion? It's happen because clojure take from in (from :state) as input from instead of honeysql/from


Your local from is shadowing the helper function from so you are effectively "calling" a long value (in from) as a function. @tajoddin.shima


Hey, possibly I’m trying to do something strongly not recommended 😄 is there a way to override a function deep down a call stack?


binding is probably better if it's only in one thread.


ie. I’m calling library.public-fn which calls library.other-fn which calls library.format-string


and I’d like to change output of format-string (say, kebab case instead of snake case)


would probably work


thanks 🙂 I’m reading the docs now!


winning 👌

Alex Miller (Clojure team)11:04:46

But this is of course a dirty thing to do and you typically shouldn’t do it unless you’re in a test


It’s a static page generator (Cryogen), so it’ll never run anywhere but my local machine. I could do this properly and duplicate a lot of the code... but it’s convenient that I don’t have to.

Alex Miller (Clojure team)11:04:17

There are also scenarios where it won’t work


@alexmiller is there another cleaner way of doing it if it's a third-party library you don't control? (except forking, changing it/making it possible to change, send patch) Feels like inherently, monkey-patching code will always be a bit dirty

Alex Miller (Clojure team)23:04:33

In Clojure, monkey-patching like this over a lib is unusual and considered bad form. It won’t compose with anything else well.


What's the implication of the difference b/w rest and next. I understand next returns nil if there are no more elements and rest returns an empty sequence instead, but I'm unable to see what difference it makes in usage.


I think that rest is kind of the more LISP-y form, whereas next is more Clojure-y


if that makes any sense at all


next is (seq (rest coll))

👍 4

in LISP, the empty list was frequently conflated with false or nil


Yeah, got that from "Clojure for LISP Programmers". Empty seqs aren't unified with false and nil because we want to distinguish b/w the kind of data structure. Thanks!


yep. next might be better to use when e.g. recursing through a list. that way you can just check for nil instead of having to call empty? on the next result

💯 4

comes down to, do you want nil or an empty coll as a return value?


you may want one or the other


yep. next might be better to use when e.g. recursing through a list. that way you can just check for nil instead of having to call empty? on the next result

💯 4

Autocomplete has stopped working for me, for "js" in clojurescript, like (js/ using cider and emacs. Anyone else who have had the same issue? I am using Figwheel


@jarvinenemil Maybe ask in #lein-figwheel or #emacs if no one is around here to help?


How do I literally get val1 from x (`(def x {-1 nil, 1 "val1", 2 "val2", 3 "val3"})`) by val1. not (get x 1)? I need to do that because x is used as an enum.

Lennart Buit20:04:05

so you want to do a reverse lookup?

Lennart Buit20:04:24

otherwise, elaborate ^^!


This is what I need but how can I simplify it: (get x (get (clojure.set/map-invert x) "val1"))


You could also use clojure.core/some.


If you want the symbol val1 you might wanna store symbols in the map (def x '{1 val1 2 val2}) and do (get x 1), or you can call symbol on the return value to create the symbol val1 out of the string "val1". I strongly suspect you're doing something that isn't idiomatic, and so more context would be helpful.


Very likely but it's a complex system that I am not ready to introduce changes to


The result is basically the same result of (get x 1) but I want the code to show val1 is being used instead of 1, if possible without the complexity of (get x (get (clojure.set/map-invert x) "val1"))

Lennart Buit21:04:03

wait huh, this will just give you “val1”, doesn’t it? But only if it was in the vals of the map to begin with

Lennart Buit21:04:32

that’s a strange way to navigate a map, from right to left to right. I don’t think we (-- or at least I, can only speak for myself --) can offer much help in “simplifying” that other than urging you to reconsider this solution you have right now


Ok, thanks for the advice. From my perspective the previous developer should've used the keys as vals and vice versa 😕