Fork me on GitHub

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?


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.


@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 if benchmarking is important


@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


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


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