This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-20
Channels
- # adventofcode (47)
- # announcements (3)
- # aws (29)
- # bangalore-clj (3)
- # beginners (63)
- # boot (2)
- # braveandtrue (40)
- # calva (34)
- # cider (37)
- # cljs-dev (8)
- # clojars (3)
- # clojure (45)
- # clojure-europe (2)
- # clojure-france (4)
- # clojure-india (2)
- # clojure-italy (44)
- # clojure-japan (4)
- # clojure-nl (39)
- # clojure-serbia (1)
- # clojure-spec (21)
- # clojure-uk (75)
- # clojurescript (28)
- # cursive (24)
- # data-science (3)
- # datomic (31)
- # emacs (13)
- # fulcro (35)
- # hoplon (21)
- # jobs-discuss (66)
- # nrepl (18)
- # off-topic (72)
- # pathom (35)
- # re-frame (20)
- # reagent (54)
- # shadow-cljs (35)
- # spacemacs (9)
- # specter (8)
- # sql (13)
- # testing (9)
- # tools-deps (21)
- # vim (3)
Hello everyone :) I would be interested to know if there exist a guide to show how to share local lib in CLJS?
hello, I mostly got down the basics of clojure, but I'm a bit lost at how to continue. I don't have many ideas for fun projects, but if I do come up with one I usually can't really implement it. any tips?
@shin try some of these https://purelyfunctional.tv/guide/programming-projects-resume/
@clojuregeek thanks very much, I'll have a look!
I've found these pretty fun to do in clojure: https://robertheaton.com/2018/12/08/programming-projects-for-advanced-beginners/
Hi. A Java class method won't accept a reified Java interface on account of (it would seem) the interface having type "reify" and thus not having the type of the Java interface. What can I do to solve this?
I'm trying to come up with a way to check which number in a list my number is closest to. like if I have 3.54 and my list consists of (2 4 6 etc.) how can I find out it's closest to 4 in a functional way? I keep coming up with loops which seems too imperative
map distance of 3.54 to every element in list, keep the minimum?
@shin you can do something like the folowing:
(let [x 3.54
values [2 4 6]
distance (fn [z] (.abs js/Math (- z x)))]
(->> values
(map (juxt identity distance))
(sort-by second)))
(first (sort-by #(abs (- 3.54 %)) [1 2 3 4]))
dpsuttonās impl is using the JS runtime, be wary of that ^^
(defn abs [n] (max n (- n)))
is what i used
not sure what the spread js/jvm users is actually
yeah, but (.abs js/Math ā¦)
certainly doesnāt š
min-key looks a lot better for this (apply min-key #(Math/abs (- % 3.54)) [-3 1 4])
In core async, there is put!
and >!!
right, one being āfire and forgetā, the other being blocking if I understand correctly. What would be a downside of using put!
except for the obvious ānot knowing whether the message was processedā?
none - put! is considered lower level (>!! is built on it) but either is fine
Right, so if I want āfire and forgetā, put!
is also fine. Thanks!
yep, thatās what itās for
if i do lein run
, can i connect to it with lein repl :connect
with the correct settings? I have a .nrepl-port
file, but i'm getting Connection refused
- something in the project.clj
?
lein run
does not start an nREPL server (unless your app starts one explicitly).
is there a way to attach to the running process with a repl? (or, in dev, how would i start the repl server?)
basically, i want my process to be running in a container off in my "bunch of docker container servers" stuff, and if needed, connect up a repl and operate via that within the context of the running app
My best guess would be try taking a look at https://github.com/clojure/tools.nrepl#embedding-nrepl-starting-a-server
@hoopes Another approach to consider is to provide JVM options when starting your process that tell Clojure itself to start a Socket REPL on a specific port, and then you can either connect via telnet/netcat or use Unravel to connect (which provides a much nicer REPL experience).
It depends whether you actually need nREPL in the mix.
awesome - thanks @trailcapital and @seancorfield - much appreciated
@hoopes see https://clojure.org/reference/repl_and_main#_launching_a_socket_server
and https://github.com/Unrepl/unravel if you want to use that
I wish the socket REPL had a little bit wider support. I do almost all of my development with apps deployed in docker - then use vim-fireplace to connect to the open nREPL, which doesn't support socket REPL. Maybe one day!
The Unrepl folks are working with the nREPL folks now so that may well become a reality -- I believe their goal is to allow an nREPL client to automatically upgrade a Socket REPL to nREPL...
hello, i have a question regarding namespaced hash-maps. looks like the namespace for a hash-map is only applied to the top level keys not applied to the child hash-maps.
are the keys for a nested hash-map not namespaced on purpose or am i not using this feature correctly?
just want to step back a second to make an important point. When you say ānamespace for a hash-mapā, hash maps do not have a namespace - this is syntax only. #:foo{:bar :eh}
is the identical value to {:foo/bar :eh}
- they are just two different syntaxes.
but yes, the syntax only extends to the top level keys in the map
(or symbols!)
i want to do POSTs from my CLJS app...
What's the best cure for my ailment?
Nevermind...
Hi i has another question that is n00b worthy
{:status 200 :session (assoc session :uid user-id)}
... I want to associate more than just :uid user-id
... for example, i'd like to add :uid user-id
and :auth-key $yag
and :login-time 7164516721
.... Can I simply assoc
the whole map?
You can make a single call to assoc
that takes an arbitrary map, and one new key-value pair to add to it, or a list of several new key-value pairs to add.
If you have two arbitrary maps you want to combine in some way, merge
or merge-with
are worth looking into
I spoke imprecisely there - assoc
does not take a list, but you can give multiple arguments with multiple key1, value1, key2, value2, etc. arguments
Oh that's just as good
Thank you. I was getting wrong number of args
let's see ...
maybe merge
is the right move
If any of those are conditional, then cond->
is great for that