This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-13
Channels
- # announcements (1)
- # bangalore-clj (1)
- # beginners (47)
- # boot (16)
- # calva (33)
- # cider (14)
- # clj-kondo (3)
- # clojure (46)
- # clojure-india (1)
- # clojure-italy (6)
- # clojure-nl (4)
- # clojure-uk (5)
- # clojurescript (10)
- # dirac (8)
- # emacs (1)
- # fulcro (1)
- # leiningen (14)
- # lumo (1)
- # off-topic (178)
- # pathom (9)
- # planck (17)
- # quil (2)
- # reagent (5)
- # reitit (6)
- # shadow-cljs (55)
- # tools-deps (3)
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:
{:deps
{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" java.io.FileNotFoundException: Could not locate sindu/migration__init.class, sindu/migration.clj or sindu/migration.cljc on classpath.
at clojure.lang.RT.load(RT.java:466)
at clojure.lang.RT.load(RT.java:428)
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(RestFn.java:408)
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(RestFn.java:142)
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(RestFn.java:137)
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(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:37)
What am I doing wrong?@UC1DTFY1G hey, are you dumrat on the Project Euler forums? Nice to see you here! One of the only other Clojurians on there.
@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)
I did the first 92, and got stuck with 93 and sort of gave up. Never really got into the harder ones I guess.
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
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.
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
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.
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
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
Your local from
is shadowing the helper function from
so you are effectively "calling" a long value (in from
) as a function. @tajoddin.shima
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?
will do, thanks @seancorfield
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.
so you want to do a reverse lookup?
If thats the case you can use map-invert: http://clojuredocs.org/clojure.set/map-invert
otherwise, elaborate ^^!
This is what I need but how can I simplify it: (get x (get (clojure.set/map-invert x) "val1"))
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.
This is what I need but how can I simplify it: (get x (get (clojure.set/map-invert x) "val1"))
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"))
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
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