Re: apply function incongruity
Konrad Hinsen <[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <[email protected]> |
On 27/06/2018 20:33, Michael Rice wrote: > Welcome to DrRacket, version 6.7 [3m]. > Language: R5RS; memory limit: 128 MB. > > (apply and '(#t #t #f #t)) > . and: bad syntax in: and > > (apply + '(1 2 3)) > 6 > > (and #t #t #f #t) > #f > > (+ 1 2 3) > 6 > > Why do they differ? + is a function, and is a macro or syntax transformer, depending on your terminological preferences. apply is a function as well, taking another function (+ in your case) as its first argument. You can't pass in and, which in fact corresponds to nothing at all at the runtime of your program. The compiler replaces it with other code. In your particular case, with all arguments constant, the compiler replaces (and #t #t #f #t) by just #f. Using and anywhere else than as the first symbol of a list is a syntax error, as you have found out experimentally. Konrad. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.