This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (23)
- # boot (84)
- # braid-chat (2)
- # bristol-clojurians (1)
- # cider (53)
- # cljs-dev (34)
- # cljsrn (13)
- # clojure (138)
- # clojure-dusseldorf (5)
- # clojure-italy (1)
- # clojure-russia (164)
- # clojure-uk (41)
- # clojurescript (80)
- # clr (2)
- # core-async (6)
- # core-logic (25)
- # core-matrix (14)
- # cursive (10)
- # data-science (4)
- # datomic (4)
- # emacs (3)
- # funcool (6)
- # hoplon (127)
- # jobs-discuss (4)
- # keechma (36)
- # ldnclj (5)
- # lein-figwheel (5)
- # off-topic (5)
- # om (155)
- # onyx (72)
- # overtone (16)
- # parinfer (39)
- # planck (3)
- # protorepl (1)
- # re-frame (11)
- # reagent (5)
- # untangled (22)
@seancorfield: right you were, it wasn't terminating for zero. Thanks! Obvious in retrospect...
i've been pretty spoiled in python by the pudb debugger - https://pypi.python.org/pypi/pudb - I was wondering if there was anything of the sort that i've been missing in clojure? i've been doing my best on repl-driven dev, but sometimes I want to stop code execution and inspect things that i've been given by code i haven't written (say, the request object in compojure in a handler function). i've been stuck on
println, but that makes it a bit more difficult to inspect large data structures. any pointers would be greatly appreciated. thanks!
Hi all! I'm just getting started with Clojure, and I'm trying to determine an idiomatic way to flatten a list so that its elements may be used as the arguments to a function. I'm coming from Python, where I would use the splat operator.
I've Googled around and found an SO answer suggesting that I do something like
(defn splatten [f [a b c]] (f a b c)). This works for my tiny problem, but I'd like to generalize this behavior. I've done so with
eval, but I understand this to be a Bad Idea:
(defn splatten [f args] (eval (conj args f)).
Any suggestions on how to generalize this behavior? I'm wishing for
(defn splatten [f [& args]] (f args)), but my REPL has declined my request.
For context (to keep this from being an xy-problem), my actual goal is to read a line from a file (check), trim and split on whitespace (check), and then pass the contents of
string/split as function parameters.
@mfikes Ah, it is indeed just
apply. This is why I was confused by the (marginally related) SO answer I found - I had confused
map. Thanks for the clarification!
EDIT: This also might explain why it was so hard to find discussion of how to "solve" this problem.
@hoopes: I never used pudb but in clojure land I know of cursive which supports debugging and emacs. I only tried the debugger coming with cursive which I find to be good enough. Although I almost never use it. Plumatic schema and unit tests are enough 99% of the time for me.
yep, i hear you on that for sure, and it seems like a lot of people hold that opinion, so i must be thinking about it wrong - i've just found it super useful in the past to pause and inspect data
like "i know that my posted data must be in this request map from compojure somewhere...let me stop in my handler function, and see which key it's in"
Been trying to figure out how to call a time method correctly from java. How would I call this in clojure
I know I can do this
(java.time.Instant/now) but not sure how to call other method
@hoopes: You definitly can do that. Start the repl in cursive in debug mode and set your breakpoints, inspect the data. No problem. You can do it now and here 😉
(.getEpochSecond (java.time.Instant/now)) Something like that. It’s just a regular method call on a java object (the one returned by now()).
(.. java.time.Instant (now) (getEpochSecond)) is another option based on this…
>(.. System (getProperties) (get "os.name"))
>(. (. System (getProperties)) (get "os.name"))
@jeff.engebretsen: Thanks. Very helpful. Interop has been confusing starting out.
Agreed. Don’t forget about the sweet page on it. http://clojure.org/reference/java_interop