The indentation was correct by got messed up when I copying the code.

This is how I interpret the function:
'expr' is only returned if (coll? expr) returns 'false', with is not
the case with an argument such as '(+ 2 4).
Next, this expression is destructured in the 'let' and 'prefix-
>postfix called again:

[ (prefix->postfix 2) (prefix->postfix 4) +]

As 2 and 4 are both not a collection, their values are just returned.
This should lead to this final result:

[2 4 +]

However, no vector is returned, just the initial argument to the
function.

I really want to understand what I did wrong here :-)

Stefan



On Sep 9, 9:08 pm, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> Yes.
>
> Have someone (for example your editor), do your indentation for you.
> By typing on tab on a good editor, you would have has:
> (defn prefix->postfix [expr]
>    (if (coll? expr)
>      (let [ [op arg1 arg2] expr]
>        [ (prefix->postfix arg1) (prefix->postfix arg2) op]))
>    expr)
>
> which is easier to diagnose. (At least for me)
>
> Have fun with recursion,
>
> Nicolas.

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

Reply via email to