@ Nicolas and ajuc

Thank you very much for showing me where I went wrong! With so many
parentheses it sometimes happens that I misplace one

Now the output of the function is as expected:

(defn prefix->postfix [expr]
  (if (coll? expr)
    (let [ [op arg1 arg2] expr]
      [ (prefix->postfix arg1) (prefix->postfix arg2) op])  ;; <--
removed on parenthesis here
  expr))

(prefix->postfix '(+ 2 (* 3 2)))
;; --> [2 [3 2 *] +]

There is just one point I still don't quite understand. That is,
during one of the recursive calls, the expression (* 3 2) is passed as
an argument to prefix->postfix:

(prefix->postfix (* 3 2))

As prefix->postfix is a normal function and not a macro, (* 3 2)
should get evaluated BEFORE being passed to the function. However,
this is not the case here.

Could it be that because (* 3 2) is quoted, because the initial
argument to the function, '(+ 2 (* 3 2)), was quoted?

Could it be that because the initial argument to prefix->postfix, '(+
2 (* 3 2)), is quoted, (* 3 2) is also quoted and therefore does not
get evaluated?

Stefan

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