[plt-scheme] Re: Simple procedure building question
I was thinking that you want to end up with the list (f x (g x (m x (n x
y)))).
But if you want to eval the expression (f x (g x (m x (n x y)))) you just do
(define (B lst x y)
(if (null? lst)
y
((car lst) x (B (cdr lst) x y))))
-----Message d'origine-----
De : plt-scheme-bounces at list.cs.brown.edu
[mailto:plt-scheme-bounces at list.cs.brown.edu] De la part de blockstack
Envoyé : October-20-08 4:20 PM
À : plt-scheme at list.cs.brown.edu
Objet : [plt-scheme] Re: Simple procedure building question
doesn't the quote prevent the inner procedures in the else-expr from
being evaluated?
On Oct 20, 3:02 pm, "Andre Mayers" <andre.may... at usherbrooke.ca>
wrote:
> (define (B lst x y)
> (if (null? lst)
> y
> `(,(car lst) ,x ,(B (cdr lst) x y))))
>
> -----Message d'origine-----
> De : plt-scheme-boun... at list.cs.brown.edu
> [mailto:plt-scheme-boun... at list.cs.brown.edu] De la part de blockstack
> Envoyé : October-20-08 3:56 PM
> À : plt-sch... at list.cs.brown.edu
> Objet : [plt-scheme] Re: Simple procedure building question
>
> correction: i meant to have y for the then-expr
>
> (define (B lst x y)
> (if (null? lst)
> y
> ((car lst) x (B (cdr lst) x y))))
>
> On Oct 20, 2:51 pm, blockstack <blockst... at gmail.com> wrote:
>
> > I want to be able to pass a list of function names and create a
> > procedure
> > lst would be something like (f g m n) where f, g, m, and n are names
> > of functions
>
> > (define (B lst x y)
> > (if (null? lst)
> > x
> > ((car lst) x (B (cdr lst) x y))))
>
> > I want to end up with a list like
> > (f x (g x (m x (n x y))))
>
> > I know that my current procedure won't return a list, but I know that
> > it must be really simple to make it do so.
>
> > I've tried different ways of using 'list' and cons, but I just can't
> > get it.
> > any help?
>
> > _________________________________________________
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
_________________________________________________
For list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme