Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!jaffer From: jaffer@zurich.ai.mit.edu (Aubrey Jaffer) Newsgroups: comp.lang.scheme Subject: Re: Logic does not Apply Message-ID: Date: 30 Apr 91 16:47:10 GMT References: <9104300906.aa04392@mc.lcs.mit.edu> Sender: news@ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 25 In-reply-to: STCS8004%IRUCCVAX.UCC.IE@mitvma.mit.EDU's message of 30 Apr 91 12:36:00 GMT > One might expect (naively?) that > > (apply bin-op (list item1 item2)) = (bin-op item1 item2) > > for *all* bin-ops, provided that bin-op's arguments are compatible with it. > But it is not so, since instead of the expected > > (apply and '(#f #t)) --> #f > > one gets some grumble that either 'and' is an undefined variable or it is > not the right kind of parameter-1 to 'apply'. The problem you are having here is that `and' and `or' are poorly named control structures. What you want are `and?' and `or?' anyway since tests are supposed to end with `?'. (define (and? . args) (cond ((null? args) #t) ((car args) (apply and? (cdr args))) (else #f))) (define (or? . args) (cond ((null? args) #f) ((car args) #t) (else (apply or? (cdr args)))))