On 20-Aug-07, at 5:34 PM, naruto canada wrote:
I'm not sure what you tried but Gambit supports a multiple argument apply (the last argument is a list of the remaining arguments. So:
(apply + '(1 2 3 4))
10
(apply + 1 '(2 3 4))
10
(apply + 1 2 '(3 4))
10
(apply + 1 2 3 '(4))
10
(apply + 1 2 3 4 '())
10
Marc
You are right, I had a mismatch of arity. It works now. Still, both methods should be equivalent.
In general (apply E1 E2) != (eval (cons E1 E2))
because eval tries to recursively evaluate its argument. It will try to evaluate the **result** of evaluating E1, and all the elements of the list **resulting** from the evaluation of E2. With apply the second round of evaluation does not occur.
Note that sometimes there is no difference because
5 = (eval 5) = (eval (eval 5)) = ...
but in other cases there is a difference because
car = (eval 'car) != (eval (eval 'car)) != ...
Marc
Afficher les réponses par date
On 8/21/07, Marc Feeley feeley@iro.umontreal.ca wrote:
On 20-Aug-07, at 5:34 PM, naruto canada wrote:
I'm not sure what you tried but Gambit supports a multiple argument apply (the last argument is a list of the remaining arguments. So:
(apply + '(1 2 3 4))
10
(apply + 1 '(2 3 4))
10
(apply + 1 2 '(3 4))
10
(apply + 1 2 3 '(4))
10
(apply + 1 2 3 4 '())
10
Marc
You are right, I had a mismatch of arity. It works now. Still, both methods should be equivalent.
In general (apply E1 E2) != (eval (cons E1 E2))
because eval tries to recursively evaluate its argument. It will try to evaluate the **result** of evaluating E1, and all the elements of the list **resulting** from the evaluation of E2. With apply the second round of evaluation does not occur.
Note that sometimes there is no difference because
5 = (eval 5) = (eval (eval 5)) = ...
but in other cases there is a difference because
car = (eval 'car) != (eval (eval 'car)) != ...
Marc
I better stick with eval then, because I have no idea how the data structure for my proof system are going look like. for example, right now it looks like: (define proof-system (list (list 'taut1 '(=> A (=> B A)) ) (list 'taut2 '(=> (=> A (=> B C)) (=> (=> A B) (=> A C))) ) (list 'taut3 '(=> (=> (not B) (not A)) (=> (=> (not B) A) B)) ) ))
I don't know if single layer apply will work for my purpose later on, I better make sure eval works.