Fork me on GitHub
#beginners
<
2016-04-05
>
morland06:04:16

@seancorfield: right you were, it wasn't terminating for zero. Thanks! Obvious in retrospect...

hoopes12:04:32

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!

eenblam12:04:31

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.

eenblam12:04:10

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.

mfikes13:04:05

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

eenblam13:04:41

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

sveri16:04:49

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

hoopes16:04:02

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

hoopes16:04:51

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"

dfcarpenter16:04:16

Been trying to figure out how to call a time method correctly from java. How would I call this in clojure

Instant.now().getEpochSecond()

dfcarpenter16:04:16

I know I can do this (java.time.Instant/now) but not sure how to call other method

sveri16:04:34

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

hoopes16:04:12

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

sveri16:04:49

No problem, your welcome

jeff.engebretsen16:04:33

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

dfcarpenter17:04:04

@jeff.engebretsen: Thanks!

jeff.engebretsen17:04:41

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

jeff.engebretsen17:04:32

If you like the ordering better.

dfcarpenter17:04:58

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

jeff.engebretsen17:04:37

Agreed. Don’t forget about the sweet page on it. http://clojure.org/reference/java_interop

dj19:04:34

hello @mjturner ! simple_smile

mjturner19:04:10

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