Re: let binding and recursive function

2010-08-04 Thread Emeka
Hello John, I would want to add something to what Justin said. (defn goo [ i k l] (println l)) = (goo 2 3 [233]) ;;; gives ([233]) (conj '([233]) ...) (defn goo [i k [l]](println l)) =(goo 2 3 [233]) ;;; gives [233] (conj [233] ...) Hope the difference is clear now. Emeka On Mon, Aug 2,

let binding and recursive function

2010-08-02 Thread John Sanda
I've just implemented an inorder traversal function for a vector-based tree. The functions look like, (defn- do-traversal [tree idx traversal] (cond (not (node-exists? tree idx)) traversal (leaf? tree idx) (conj traversal (tree idx)) :else (apply conj (do-traversal tree

Re: let binding and recursive function

2010-08-02 Thread Justin Kramer
I think you want: (defn- do-traversal [tree idx [tree-traversal]] ...) Note the extra brackets for destructuring. Another alternative is using multiple arg lists: (defn- do-traversal ([tree idx] (do-traversal tree idx [])) ([tree idx traversal] ...)) Lastly, FYI, the form (if

Re: let binding and recursive function

2010-08-02 Thread John Sanda
Thanks for the response and suggestions Justin. A co-worker also just suggested multiple arg lists which is perfect. He also suggested (or foo bar) to further simplify my code. It definitely cleans the code up and improves readability. - John On Mon, Aug 2, 2010 at 5:37 PM, Justin Kramer