This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-04
Channels
- # aleph (4)
- # bangalore-clj (1)
- # beginners (89)
- # boot (16)
- # braveandtrue (4)
- # cider (1)
- # cljs-dev (6)
- # cljsrn (90)
- # clojure (132)
- # clojure-austin (1)
- # clojure-dusseldorf (4)
- # clojure-italy (12)
- # clojure-portugal (2)
- # clojure-spec (13)
- # clojure-uk (41)
- # clojurescript (142)
- # code-reviews (19)
- # conf-proposals (1)
- # datascript (6)
- # datomic (7)
- # graphql (12)
- # jobs-discuss (3)
- # keechma (23)
- # leiningen (3)
- # lumo (22)
- # off-topic (7)
- # om (21)
- # onyx (8)
- # parinfer (46)
- # pedestal (3)
- # perun (3)
- # re-frame (10)
- # reagent (30)
- # ring (1)
- # rum (2)
- # spacemacs (1)
- # sql (2)
- # testing (17)
- # yada (32)
This was working two weeks ago, breaks today when I launch CIDER from within the project.
error in process sentinel: Could not start nREPL server: Could not find artifact org.clojure:clojure.math.numeric-tower:jar:0.0.4 in central ( )
Could not find artifact org.clojure:clojure.math.numeric-tower:jar:0.0.4 in clojars ( )
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the ’http_proxy’ environment variable.
Per
, there has been no change in version number. No change to my files, either. And no network issues here. But when I look at those URLs, I don't find anything looking like the specified artifacts.
Any ideas how to proceed? @seancorfield @noisesmith thanks for all the help. I've learned a lot, but with the super-optimized version it's still taking over a minute with 100003 and my goal was under 12 seconds with 1000003
curious, what would you do in the for bindings to optimize? (btw for is not a loop, it's a lazy sequence comprehension)
@noisesmith sorry too many years of java, my keyboard autocompletes for to for loop lol
just as long as we all understand the difference 😄
okay so I can use a let binding in the for comprehension, so I need to derive the j value so I don't have to create two giant lists of numbers
but for doesn't create two giant lists of numbers
range is lazy, and nothing holds the head of those ranges
only one element at a time has gc root for each sequence feeding the two bindings
(well that's a simplification, it could be that chunk-size items at a time exist - something around 32 - I forget - but not your total input)
benchmarking this stuff is tricky; I might have to run this through sayid. but for now I'll sleep on it. posturepedic driven development
visualvm or yourkit would verify where the remaining bottlenecks are in the code
Hi everyone, when trying to do this (apply case job-type jobs)
, I get "Can't take value of a macro". I think I understand why it can't, but can't figure out a solution. Any suggestions?
@jlmr Yeah you can't do that with a macro. You can use the some
function though to iterate over your jobs
case can be replaced with a hash-map lookup where the value in the map is a function you call
First time writing macros, I'm trying to iterator over an argument list and basically get a map of {(keyword arg) ~arg}
(so {:ref "value-of-ref"}
if arg is ref
). I have:
(defmacro defaction [spec fields]
`(defn ~(symbol (str "make-" (name spec))) ~fields
(s/conform ~spec (apply merge {:type (->SCREAMING_SNAKE_CASE (name ~spec))}
(for [f fields]
{(keyword f) ~f})))))
but I get CompilerException java.lang.RuntimeException: Unable to resolve symbol: f in this context
, can anyone point out what I'm doing incorrectly?also, the logic of that macro won’t work unless fields is a literal
(you might already realize this)
I'm basically trying to have a generic way of generating constructor functions off of a spec and a list of keys
so (defaction ::some-spec [ref value])
will become (defn make-some-spec [ref value] ..build map...)
no you want a in front of from in front of spec and f(apply
, and you want to remove the
Final form:
(defmacro defaction [spec fields]
`(defn ~(symbol (str "make-" (name spec))) ~fields
(s/conform ~spec ~(apply merge {:type (->SCREAMING_SNAKE_CASE (name spec))}
(for [f fields]
{(keyword f) f})))))
@noisesmith @seancorfield my solution came down to simple algebra again 🤓
remember I wanted to find number pairs only using one list so I was wondering if there was a way to calculate a valid corresponding j for every i
oh of course there’s a math answer to that
but then when I was doing the dishes I thought "maybe I don't need to test every pair" so I tried to come up with a number j for every i that was a potential solution for the problem
I wracked my brain and then decided to just sleep on it and this morning it hit me that I just need to write out an equation and isolate the number I'm looking for
but the results seemed to be off a little so I just added 1 to the denominator and ended up with j = (sum - i)/ i + 1
then I printed out all the pairs using 26 as the upper bound because I know which pairs are right for that number
so once again I saw the obvious answer in front of me; if i15 = j21 then i21 would equal j15 but once again to be able to do that kind of simple observation you would have to hold on to the entire collection
then there were some j values that were larger than the upper bound of the collection so they were out
After I filtered all of the j values like that out the only thing left was a good value for j
there’s room for some easy optimizations there btw
(vec (remove nil? (map f coll)))
will perform better as (into [] (comp (map f) (remove nil?)) coll)
also, what is (long j)
intended to do? I think you can just use j
there
oh wow, you're right, my version processed the value 1,000,003 in 932 msecs and your suggestions got it down to 261 msecs
yeah - that’s the thing I love about transducers is the rewrite is usually trivial (it could be done by an editor macro) and the improvement is often quite substantial
you could also try replacing (comp (map f) (remove nil?))
with (keep f)
now that I think of it
oh whoops, I didn't see that you turned it into a transducer, all I did was change vec to into []
that should also make a speed improvement
with keep or map/remove ?
nice!
This is amazing, a function that used to heat up my laptop, eat up all my RAM and cpu when it got a value over 50,000 now returns in nanoseconds on values over a million
also the code hasn’t become harder to read
on the contrary, imho
Trying to port to Clojure the Java API demo for the Netica Bayesian inference engine---knowing about Java only what I've read in Clojure for the Brave... So far, I have dealt with two Java import
statements by including like content in an :import
clause in core.clj's ns
form and a :java-source-paths
clause in the defproject
(full clauses appended). CIDER loads all this without complaining. But, attempting to translate this line...
Node.setConstructorClass ("norsys.neticaEx.aliases.Node");
...as...
(Node/setConstructorClass "norsys.neticaEx.aliases.Node")
...and entering at the REPL, I get this error:
CompilerException java.lang.RuntimeException: No such namespace: Node, compiling:(*cider-repl edit-server*:43:19)
.
JAR file at the above-specified path includes norsys/netica/Node.class
.
Any ideas what's wrong here? Hoping I can send a successful port back to Norsys.
Full clauses:
:java-source-paths ["c:/NeticaJ_Win/NeticaJ_504/bin"] ; Abolute path ok? Example: src/main/java
...
(:import [norsys.netica.*]
[norsys.neticaEx.aliases.Node])
@bschrag .* doesn’t work
right
Trying something maybe simpler: Added [norsys.netica.Environ]
(also in JAR) to :import
, entered (Environ. null)
at REPL. Got...
CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Environ, compiling:(*cider-repl edit-server*:43:19)
odd that it didn’t complain about null
did you reload the code after adding the import? either the import should have failed or calling the constructor should have gotten a different error (or worked)
OK, then (Environ. nil)
should work, also you can use the classes without import in the repl
invoking (narsys.netica.Environ. nil)
is ugly, but it can make sense while experimenting at the prompt
edit-server.core> (norsys.netica.Environ. nil)
CompilerException java.lang.ClassNotFoundException: norsys.netica.Environ, compiling:(*cider-repl edit-server*:45:19)
have you restarted the repl since adding the narsys dep to your project?
either that or it’s a typo in the name somewhere
also you can just refer to a class to verify it exists
=> java.util.Map
java.util.Map
=> this.does.not.Exist
CompilerException java.lang.ClassNotFoundException: this.does.not.Exist, compiling:(/private/var/folders/xb/gyyjxv511q7d9lr24s9_1rzc0000gr/T/form-init6129334502306779478.clj:1:1344)