This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-06
Channels
- # announcements (3)
- # aws (23)
- # beginners (61)
- # calva (57)
- # cider (121)
- # clara (1)
- # clj-kondo (9)
- # cljs-dev (62)
- # cljsrn (3)
- # clojure (79)
- # clojure-europe (2)
- # clojure-nl (19)
- # clojure-spec (9)
- # clojure-uk (14)
- # clojurescript (92)
- # clojureverse-ops (2)
- # cursive (3)
- # data-science (2)
- # duct (1)
- # figwheel (2)
- # graphql (6)
- # jobs (1)
- # kaocha (5)
- # leiningen (11)
- # off-topic (25)
- # overtone (1)
- # pedestal (4)
- # portkey (1)
- # re-frame (1)
- # remote-jobs (2)
- # shadow-cljs (179)
- # slack-help (3)
- # specter (7)
- # testing (14)
- # tools-deps (14)
- # unrepl (12)
- # vim (2)
- # yada (3)
Is there any way to use type hints to improve performance on JVM arrays of BigInteger
s? Looks like I can use ^BigInteger
when aset
ting single values, but there seems to be no plural equivalent to ^longs
, ^doubles
, etc. for aget
ting values from BigInteger
arrays.
Why is
(merge-with bit-and {1 1} {5 0})
returning {1 1, 5 0}
? It should return {1 0, 5 0}
, because neither map shares a common value for a given key. I have tried writing a function to make bit-and
consider the case where one argument is nil
, but it does not seem to make a difference. What is happening here?I think you are misunderstanding merge-with, it merges the maps based on keys, since there is no conflict in the keys, there is no need to “merge” the conflicting values with the bit-and
function.
Gotcha. yeah, I noticed my print statement was not being called for non-shared keys.
Thanks! That was the last bug in my program. I ended up writing this function instead, which makes use of the useful
library (https://github.com/clj-commons/useful). Not sure if there’s a more ideal way to do this with just the standard library.
(defn common-factors
[m1 m2]
(->> (merge-with + m1 m2)
(filter-keys-by-val #(= 2 %))))
All input values will be 1 or 0.It's not so clear what the inputs to your function are supposed to be, the prime factorizations of two numbers?
eg.
(defn common-factors
[m1 m2]
(reduce-kv
(fn [acc k v1]
(if-let [v2 (m2 k)]
(assoc acc k (min v1 v2))
acc))
{} m1))
The reduce-kv
makes a lot of sense! Was definitely overthinking it. Although for my particular case, I just need to conj
the k
s to a []
. Thanks 👍:skin-tone-2:
yeah, I assumed that leaving the key out carried the same information as setting its value to zero
oh, right of course… haha Reading this over again it was obvious. Of course if any key is present in m2
but not in m1
it doesn’t matter
could whip something up with https://github.com/clojure/data.xml
If run lein with-profile clj,dev classpath
I see the dependencies that I should have access to. But when I run lein with-profile clj,dev exec test/main/clojure/path/to/myfile.clj
I get Could not locate cheshire on classpath
My project.clj has :profiles {:dev [:project/dev :profiles/dev], :profiles/dev {} :project/dev {:dependencies [...]} :clj {:dependencies [[cheshire "5.5.0"]]}}
the big clue there is to clojure there is no such thing as "cheshire" just a bunch of namespaces that start with "cheshire.*" so if the language itself was reporting an error it wouldn't refer to "cheshire" but it would refer to either a file name or a namespace name
hmm another thing is that it doesn't matter what I use in the require... I can use any lib and it will throw the exact same message
What do you mean that its some code somewhere that is causing it? The stacktrace just says that
Exception in thread "main" java.io.FileNotFoundException: Could not locate cheshire__init.class or cheshire.clj on classpath., compiling:(com/foo/bar/automated_tests.clj:1:1)
Exception in thread "main" java.io.FileNotFoundException: Could not locate etaoin__init.class or etaoin.clj on classpath., compiling:(com/foo/bar/automated_tests.clj:1:1)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.loadResourceScript(RT.java:363)
at clojure.lang.RT.load(RT.java:453)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5697)
at clojure.core$load_one.invoke(core.clj:5692)
at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
at clojure.core$load_lib.invokeStatic(core.clj:5736)
at clojure.core$load_lib.doInvoke(core.clj:5717)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$load_libs.invokeStatic(core.clj:5774)
at clojure.core$load_libs.doInvoke(core.clj:5758)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$require.invokeStatic(core.clj:5796)
at clojure.core$require.doInvoke(core.clj:5796)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$apply.invoke(core.clj:641)
at user$eval6299.invokeStatic(form-init125445217099502316.clj:1)
at user$eval6299.invoke(form-init125445217099502316.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.load(Compiler.java:7379)
at clojure.lang.Compiler.loadFile(Compiler.java:7317)
at clojure.main$load_script.invokeStatic(main.clj:275)
at clojure.main$init_opt.invokeStatic(main.clj:277)
at clojure.main$init_opt.invoke(main.clj:277)
at clojure.main$initialize.invokeStatic(main.clj:308)
at clojure.main$null_opt.invokeStatic(main.clj:342)
at clojure.main$null_opt.invoke(main.clj:339)
at clojure.main$main.invokeStatic(main.clj:421)
at clojure.main$main.doInvoke(main.clj:384)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: Could not locate etaoin__init.class or etaoin.clj on classpath.
at clojure.lang.RT.load(RT.java:456)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5697)
at clojure.core$load_one.invoke(core.clj:5692)
at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
at clojure.core$load_lib.invokeStatic(core.clj:5736)
at clojure.core$load_lib.doInvoke(core.clj:5717)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$load_libs.invokeStatic(core.clj:5774)
at clojure.core$load_libs.doInvoke(core.clj:5758)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$require.invokeStatic(core.clj:5796)
at clojure.core$require.doInvoke(core.clj:5796)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at com.foo.bar.automated_tests$eval6404$loading__5569__auto____6405.invoke(automated_tests.clj:1)
at com.foo.bar.automated_tests$eval6404.invokeStatic(automated_tests.clj:1)
at com.foo.bar.automated_tests$eval6404.invoke(automated_tests.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6916)
at clojure.lang.Compiler.load(Compiler.java:7379)
...
Tests failed.
Error encountered performing task 'test' with profile(s): 'clj,dev,dev'
Tests failed.
the names you put in project.clj are maven coordinates, the names you put in require are clojure namespace names
just searching for etaoin in github brings up https://github.com/igrishaev/etaoin which has namespaces like etaoin.api
but no etaoin
the readme for the project shows namespaces like:
(use 'etaoin.api)
(require '[etaoin.keys :as k])
(technically the names you put in project.clj are part of the maven coordinate, the other part is the version)
Can someone tell me how to pass parameter to ring
?
After reading this https://github.com/weavejester/lein-ring I've already tried:
lein ring server {:port 8881 :nrepl {:start? true :port 8801}}
and
lein ring server 8881 --nrepl {:start? true :port 8801}
How am I supposed to pass such parameters?
@luizedusol do you have a project.clj ?
great, you have a :ring
config already. additional options can be added to the map which currently specifies your handler
What's the difference b/w (fn [] ...)
and (fn foo [] ...)
.
@jaihindhreddy it also allows you to call a different arity than with recur which targets only the arity of the current body
Thanks!