Hi Laurent,
Thanks for your detailed explanation! It greatly helped me understand
the usage of quoting.
Stefan
On Sep 10, 5:27 pm, Laurent PETIT wrote:
> 2010/9/10 Stefan Rohlfing :
>
>
>
>
>
>
>
>
>
> > @ Nicolas and ajuc
>
> > Thank you very much for showing me where I went wrong! With so man
2010/9/10 Stefan Rohlfing :
> @ 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 arg
@ 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
On 9 Wrz, 15:27, Stefan Rohlfing wrote:
> 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 i
(defn prefix->postfix [expr]
(if (coll? expr)
(let [ [op arg1 arg2] expr]
[ (prefix->postfix arg1) (prefix->postfix arg2) op])) ;; HERE: 2
closing brackets first one close the let. second close the if.
expr)
In Clojure, (if test expr else) is the if expression.
Here, you do (if test t
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 call
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
On 9 Wrz, 14:30, Stefan Rohlfing wrote:
> In order to get some more insight into recursion I wrote the following
> function but ended up in confusion:
>
> (defn prefix->postfix [expr]
> (if (coll? expr)
> (let [ [op arg1 arg2] expr]
> [ (prefix->postfix arg1) (prefix->postfix arg2) o
In order to get some more insight into recursion I wrote the following
function but ended up in confusion:
(defn prefix->postfix [expr]
(if (coll? expr)
(let [ [op arg1 arg2] expr]
[ (prefix->postfix arg1) (prefix->postfix arg2) op]))
expr)
I expected the result to be a vector, su