Fork me on GitHub

@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 - - 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.


@eenblam: Perhaps your spatten would involve apply, or is apply.


@mfikes Ah, it is indeed just apply. This is why I was confused by the (marginally related) SO answer I found - I had confused apply with 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 simple_smile - 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 😉


all right then, time to learn cursive - i've been a vim diehard since forever


No problem, your welcome


@dfcarpenter: (.getEpochSecond (java.time.Instant/now)) Something like that. It’s just a regular method call on a java object (the one returned by now()).


@jeff.engebretsen: Thanks!


(.. java.time.Instant (now) (getEpochSecond)) is another option based on this… >(.. System (getProperties) (get "")) > >expands to: > >(. (. System (getProperties)) (get ""))


If you like the ordering better.


@jeff.engebretsen: Thanks. Very helpful. Interop has been confusing starting out.


Agreed. Don’t forget about the sweet page on it.


hello @mjturner ! simple_smile


Greetings @dj! I’m somehow not surprised to find you here 😉