This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-27
Channels
- # beginners (56)
- # calva (61)
- # cider (16)
- # clara (7)
- # cljdoc (2)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (144)
- # clojure-spec (23)
- # clojure-uk (5)
- # clojurescript (9)
- # clojureverse-ops (5)
- # community-development (4)
- # cursive (18)
- # datomic (15)
- # docs (6)
- # jackdaw (2)
- # nrepl (10)
- # nyc (2)
- # off-topic (18)
- # rewrite-clj (20)
- # shadow-cljs (31)
is there a way to do "categorize" an argument to a multi-method? I was going to have 3 arguments, the first two are canonical, but the 3rd has like 5 values that should go to one fn and 4 other values that should go to another fn.
what I usually do for that kind of thing is not deal with it at the multimethod level, so all values are dispatched and get their own methods, and then create a helper function that the N multimethods that share a body call
with the idea that at some point those different values may need different behaviors and having the different multimethods gives you a skeleton to put those changes on when they occur
I’m trying to install neanderthal
in my project and when I run lein deps
I get this:
Could not find artifact org.jcuda:jcuda-natives:jar:apple-x86_64:10.0.0 in central ( )
Could not find artifact org.jcuda:jcuda-natives:jar:apple-x86_64:10.0.0 in clojars ( )
Could not find artifact org.jcuda:jcublas-natives:jar:apple-x86_64:10.0.0 in central ( )
Could not find artifact org.jcuda:jcublas-natives:jar:apple-x86_64:10.0.0 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.
What is going on here and how can I get around it?
All I did was add [uncomplicate/neanderthal "0.22.1"]
to my project.clj
.Per the Neanderthal docs "Another important thing on Mac: CUDA GPU code that Neanderthal uses could not have been compiled for macOS since it is difficult to find a Mac with Nvidia hardware. That means that you have to explicitly exclude jcuda natives in your project. See how to do that in the Hello World project example."
https://github.com/uncomplicate/neanderthal/blob/master/examples/hello-world/project.clj#L6-L7
With those additional exclusions, it should work on your Mac @tabidots
(I just tried it -- never played with Neanderthal before, but I got your errors until I read a bit further and updated my project.clj
file 🙂 )
Anyone know their way around the matrix/linear algebra libraries in Clojure? I am trying for a second time, unsuccessfully, to get anything working properly. I just want to find a least-squares
solution to linear algebra equations. So far I have tried neanderthal
, clatrix
, core.matrix
, and clatrix
and I am just getting all sorts of obscure errors. I can’t even get neanderthal
properly working because I don’t have icc
(the Intel compiler that is needed to install some components… apparently it’s not free?)
the clatrix
API looks nice and simple but its least-squares
function is buried in some protocol thing (I don’t understand what that is) and it is not accessible: https://github.com/tel/clatrix/blob/master/src/clatrix/core.clj#L1798-L1801
I haven't used this library but the protocol just means that you can use the generic (lin/least-squares)
function on their matrix type
After almost an entire day, I finally made some progress with Neanderthal… (I was able to make the example in one of his blog posts work without any errors!)
If other Mac users are interested in using it, after doing the typical lein deps
configuration dance, install/refer to the following…
add this to your project.clj
:exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
[org.jcuda/jcublas-natives :classifier "apple-x86_64"]]
then…
https://software.intel.com/en-us/performance-libraries
https://github.com/firemodels/fds/wiki/Compiling-FDS-with-GNU-Fortran-in-Mac-OSX
https://github.com/firemodels/fds/wiki/Linking-to-Intel-Math-Kernel-Libraries-in-Linux-and-OSX
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/780846
https://github.com/uncomplicate/neanderthal/issues/31
Phew. Brings back memories of my first experience trying to get Numpy/SciPy/etc. working (before I even knew what Homebrew was)…Hi - I'd like to apply a function, say myfn :=
(fn [&{:keys [a b c]}] ...)
to a map, say, {:a 1 :b 2 :c 3}
Naively applying directly to the map fails with a "No value supplied for key" Error.
This works:
(let [enlist-arguments (fn [m k v] (conj (conj m k) v))
]
(apply myfn
(reduce-kv enlist-arguments [] {:a 1 :b 2 :c 3})))
But it feels clunky to me. Is there an idiomatic way of apply-ing to a map?
Thx.You can “flatten” a map into a seq of keys and vals with (mapcat identity {:a 1 :b 2 :c 3})
cljs.user> (def myfn (fn [&{:keys [a b c]}] (+ a b c)))
#'cljs.user/myfn
cljs.user> (apply myfn (mapcat identity {:a 1 :b 2 :c 3}))
6
Ah. Thanks!
And here’s another solution using transducer: (into [] cat {:a 1 :b 2 :c 3})
The difference being that mapcat
returns a lazy sequence and (into []...)
is eager and let’s you decide the output collection (vector in this case).
even better is to not use the & {:keys []}
destructuring in my opinion. Unless its just for human consumption and even then I don't really see the point
I agree with @dpsutton. I very rarely use & {:keys []}
. In most cases it’s better to just pass the map in.
Yeah I see your point.
I'm do not understand what I am doing wrong. I want to return a value from a map. I call the key to the value, but I get a nil back.
{:CBE9OAmVFBl {:folder {:title “January”, :creator_id "dfB9EAz9VDO", :parent_id "SUE9OACzt7w", :color "red", :id "CBE9OAmVFBl", :created_usec 1551219606236863, :updated_usec 1555294617961547}, :member_ids ["dfB9EAz9VDO"], :children [{:folder_id "cNS9OArNj7w"} {:thread_id "YWE9AATkW0a"}]}}
When I call (first) on it, I get [:CBE9OAmVFBl {:folder {:title "January", :creator_id "dfB9EAz9VDO", :parent_id "SUE9OACzt7w", :color "red", :id "CBE9OAmVFBl", :created_usec 1551219606236863, :updated_usec 1555294617961547}, :member_ids ["dfB9EAz9VDO"], :children [{:folder_id "cNS9OArNj7w"} {:thread_id "YWE9AATkW0a"}]}]
is it possible you have a typo? seems like you are using :CBE90AmVFBl
which has a zero in it, but the other examples you posted have a capital o like this one :CBE9OAmVFBl
if I call (first) it's almost like I get a vector with a key as it's first item in it
How are you making these maps. Are you calling keyword on some incoming data? Perhaps these keywords having non printing characters in them
if I call (second (first I get {:folder and from there I can access values with keys
That’s true. But this is just a diagnostic that the key in the map works and typing it in is where we are having an issue
My suspicion is that this will work but when you type the literal it doesn’t work. Which points to the keyword that can’t be represented as a literal
@rakyi OMG I swear I copy and pasted in the repl and it didn't work. Thanks to both you and dpsutton. I def'd some map variants of the returned Cheshire map and found out that it was a typo. Wow. I need coffee.
When would you want to use the clj command line tool vs java (also a cmd line tool?) Directly?