[gambit-list] (eval (cons func '(1 2))) don't work

naruto canada narutocanada at gmail.com
Mon Aug 20 15:06:10 EDT 2007


On 8/21/07, naruto canada <narutocanada at gmail.com> wrote:
> On 8/21/07, Etienne Laurin <laurieti at iro.umontreal.ca> wrote:
> > On Tue, Aug 21, 2007 at 02:08:43AM +0800, naruto canada wrote:
> > > ;; propositional calculator
> > > (map (lambda (p) (implies p p)) (list #t #f))
> > > (cross-product '((0 1) (0 1) (0 1)      ) )
> > > (cross-product '((0 1) (0 1) (0 1) (0 1)) )
> > > (define (prop-calc func lst)
> > >   (map (lambda (x) (eval (cons func x))) lst)
> > > )
> > > (prop-calc (lambda (p) (implies p p)) (bag-of (list (amb-list (list #t
> > > #f)))))  ;; test tautology
> > > 'done (exit)
> >
> > You can use apply instead:
> >
> >   (map (lambda (x) (apply func x)) lst)
> >
> > Unless you really need to evaluate arbitrary scheme expressions,
> > eval doesn't need to be used and shouldn't have to be.
>

oops, forgot to reply to list.

 apply won't work more then one parameters (I've tried it):
 (prop-calc (lambda (p q) (iff (implies p q) (implies (not q) (not p))))
            (cross-product '((#t #f)(#t #f)))
 )

 Besides, when I start on predicate calculus, it's going to become ugly
 (symbolic),
 I need to make sure I can still evaluate arbitrary lambdas before
 planning out data structure.


>
> >
> > Etienne Laurin
> >
>



More information about the Gambit-list mailing list