This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-23
Channels
- # announcements (2)
- # beginners (82)
- # calva (13)
- # cider (12)
- # clara (4)
- # cljdoc (22)
- # clojure (89)
- # clojure-dev (23)
- # clojure-europe (16)
- # clojure-italy (39)
- # clojure-nl (8)
- # clojure-spec (28)
- # clojure-uk (36)
- # clojurescript (40)
- # cursive (10)
- # data-science (1)
- # datomic (27)
- # devcards (4)
- # emacs (1)
- # fulcro (25)
- # jobs (1)
- # jobs-discuss (3)
- # kaocha (5)
- # luminus (1)
- # nrepl (68)
- # off-topic (64)
- # pedestal (23)
- # planck (1)
- # quil (4)
- # re-frame (6)
- # reitit (5)
- # remote-jobs (4)
- # shadow-cljs (16)
- # spacemacs (11)
- # testing (1)
If i understand correctly comp
can be substituted with ->
, so when to use comp
?
@pythonjokeun comp
produces a function. So (comp str/lower-case name)
is a function that would convert a keyword to a lower-case string.
So it can be passed around and treated just like any other function.
(-> s name str/lower-case)
works when you have a series of functions to apply to a value.
(let [lower-key (comp str/lower-case name)]
(lower-key s))
Does that help show the difference?@seancorfield yes! so comp useful when you need to produce a function, right?
another thing to consider when comparing, is that ->
takes a form as input, and produces a new form as output, before compilation happens
comp operates on functions, which are already compiled
Also, when you get to transducers, you'll see comp
used to produce a transforming function from multiple functions... https://clojure.org/reference/transducers -- shows how threading and composition compare as well.
noted, thanks!
this gives me a map: (meta (resolve 'has-email)) however, this does not work, even though the list contains has-email: (map #(meta (resolve (symbol %))) (dir clararules.core))
probably because dir
returns nil, it prints the values you're interested in as a side effect
i maybe going about this wrong... if i do load/load-string, how do i know what got loaded? like a list of functions
i'm probably thinking about this wrong... possibly i need to have expected functions to call or protocol... not sure what's appropriate.
if you're only interested in a certain subset of possible effects, I'd try capturing prior and posterior values around the load
and diffing them
in java i guess i'd be expecting some instance of a class w/methods i call, with load-string, not sure how i should go about calling into loaded functions.
then you can invoke the multimethod from java using clojure interop (there are examples)
similar but if you don't need the perf benefits of protocol or you want multiple dispatch etc, multimethods are fine (and more general)
if you're prototyping and don't have a need to use protocols, start with multimethods
It happens when I run heroku local
Sounds like your JAR file doesn't include Clojure. How was it built?
lein uberjar
i thought this would include everything it needs to make the jar run
@UD4M6JN49 Hmm, I would have expected that to work. Can you run it locally -- not on Heroku?
this problem is local
Hey team. Relatively new to Clojure from a python/django background. Trying to develop with unit tests for everything, but trying to lock down some best practices and overall testing resources. Do you have any useful links?
I read an article that recommended test suites such a Kaocha. Just don't wanna go down a rabbit hole.
On the project I'm on we just use clojure.test
. I'm sure others do it differently, but the main thing I do is have a repl open on the other side of my screen and run the (editor specific) command for running the tests in this namespace. As I'm writing the tests, I'll regularly be defining top level vars and sending forms over to the repl to see how things are working.
clojure.test
is a fine place to start. Many Clojure-aware editors have shortcut keys to run tests directly from your source files or test files. That makes a huge difference in productivity. Also check out Stuart Halloway's talks about "REPL-Driven Development" and "Running With Scissors" for good practices around REPL usage (and testing code via the REPL).
Perfect...Thank you!
I have an atom with {:id 1 :vector [1 2 3]} - So I need to update it to drop 1
(first one).
you can, but this is a very inefficient operation
if you used a list/seq, you could just use rest
the big point is - decide what operations you need on a data structure, then pick the data structure on which those exist + are fast
(and btw Clojure generally only implements the ops for data structures where it can meet some perf expectations, so if they exist, it's prob fast)
(def item (atom {:id 1 :v '(1 2 3)}))
=> #'junk.core/item
(swap! item update-in [:v] rest)
=> {:id 1, :v (2 3)}
Hello! I want to try interactively develop in tty application, particularly a want to achieve the following: I run from the clojure code "/bin/sh" "-c" "stty -echo raw </dev/tty" -> I expect to see runned empty console, after that I want to add different key press handlers etc, etc. I am confused how I can do that in interactively manner. Thank you in advance!!
@k.matush this might not be exactly what you asked for, but it might be of interest anyway: https://github.com/MultiMUD/clojure-lanterna
I'm reading through a pretty big fancy code. they have these giant maps that they pass to every function. I struggle to see what each map is supposed to look like, especially when messing with the REPL
. I've been reading about spec
s. Is a proper application of spec
to define how large map and data structures should look like? It seems as though I can define the spec
of key values that must be there, and the values that should be present for my critical data.
Concise...I love it. Thanks.
that's exactly it. if you spec your attributes/maps/functions with fspecs then you get those specs via doc
on the function, gen arg examples, instrument to check incoming values match your spec in dev, and test with check
that your function operates correctly
Thanks. Coming from a python/fortran background, clojure has been tough for me to learn, but I'm trying to set up my project right! So I'll right some spec's for the most important stuff.
java comes with that stuff, I don't know why you'd need a framework. Aleph has some nice abstractions for async and data oriented stuff on top of that though