Re: Some Problem with Recursion

2010-09-10 Thread Stefan Rohlfing
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

Re: Some Problem with Recursion

2010-09-10 Thread Laurent PETIT
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

Re: Some Problem with Recursion

2010-09-10 Thread 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 arg1 arg2] expr] [ (prefix->postfix arg1

Re: Some Problem with Recursion

2010-09-09 Thread ajuc
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

Re: Some Problem with Recursion

2010-09-09 Thread Nicolas Oury
(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

Re: Some Problem with Recursion

2010-09-09 Thread Stefan Rohlfing
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

Re: Some Problem with Recursion

2010-09-09 Thread Nicolas Oury
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

Re: Some Problem with Recursion

2010-09-09 Thread ajuc
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

Some Problem with Recursion

2010-09-09 Thread Stefan Rohlfing
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