Fork me on GitHub
#beginners
<
2015-10-25
>
binduwavell18:10:04

Hi, I'm working through Clojure for the brave and true... I had the darnedest time implementing my own version of comp. I did finally get it working a couple of different ways. My recursive implementation is faster than my implementation that uses recur... I imagine there is an idomatic way of deferring logic until you reach the end of your "recursion" and then compute as things unwind... Is this an appropriate place to ask questions about what is going on?

binduwavell18:10:30

I have been measuring times in a REPL. I was just reading some about Clojure performance and one commenter suggested that it's probably not super smart to (time) stuff in a REPL... I'll try running some timings using lein. I'm also interested if there is an common way to use (recur) and defer computation until things unwind (maybe the point of recur is you can't do this?) More likely I'm just not getting the functional way of thinking yet.

xeqi21:10:15

@binduwavell: this is an appropriate place, but it might be a bit slow on weekends. Timing stuff with lein repl is not recommended as it uses some jvm flags that optimize start time vs performance. I've seen many references to https://github.com/hugoduncan/criterium if benchmarking is important

xeqi21:10:50

@binduwavell: as far as delaying computation, it will depend on exactly what you're doing. Wrapping things in a fn can delay them until the function is called. lazy-seq is useful to delay computation for a sequence of items

binduwavell21:10:25

Thanks @xeqi, I'll check criterium. If I want to post some sample code, is there a "proper" way of doing that here?

xeqi21:10:22

if its a few lines then ` could work. Otherwise a paste site / gist is fine