Am Dienstag, 10. September 2013 01:24:10 UTC+2 schrieb Igor Demura:
>
> Hi Clojure community,
>
> (I tried codereview.stackaxchange.com before, but no responses where) I'm 
> Clojure newbie, and feel very excited about it and functional programming 
> in general. I wrote tiny app (59 lines of code) which renders a directory 
> tree to the terminal, filtering with a regex. I'm sure that my code is not 
> perfect and something could be done much better. I'll appreciate if you 
> could spent sometime to review it: 
> https://github.com/idemura/incub/tree/master/tree. Don't know where to 
> get help with this.
>
> (str (reduce #(str %1 " " %2) coll)

can be replaced with clojure.string/join 

(iterate inc 1) 
=> (rest (range)) may be more clear

(alter-var-root #'*read-eval* (constantly false))
=> why do you think this is necessary?

You can convert the regex string into a pattern once in line 51:
(when regex (re-pattern regex))

(assoc m p (conj (m p []) f))
=> (update-in m [p] (fnil conj []) f)) 

In general I would separate the different task:

* directory tree walking -> tree representation
* render tree into line definitions
* render tree lines into string
* print string

-billy



 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to