This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: trouble with predicate of defined-record-type
Mike wrote:
> I am fairly new to
> Scheme, so its most likely something dumb on my part.
I'm afraid so ...
(every rec? (list a b))
returns true (as expected), but
(every rec? '(a b))
The latter is loosely the same as:
(every rec? (list 'a 'b))
I.e. you're checking that each *symbol* 'a and 'b is a rec? - which is
false: The type is a symbol, not a rec.
(The difference between '(a b) and (list 'a 'b) is irrelevant in this
context, but it is whether the list is constructed once (when the
expression is read), or multiple times (each time the expression is
evaluated.)
unexpectedly returns false. However if I use a 'normal' procedure such as this
(define less-than-3? (lambda (n) (< n 3)))
then both of the following return true, as I would think they should:
(every less-than-3? (list 1 2))
(every less-than-3? '(1 2))
The difference is that 1 and 2 are "self-evaluating". Evaluating 1
returns 1. Hence '1 is the same as 1. Evaluating 'a yields a symbol,
while evaluating a yields what is bound to the name a.
Also, if comp.lang.scheme or the like would be more appropriate for
this sort of question, please let me know.
Probably. We don't mind a few newbie questions (it makes us feel good
that new people are discovering and trying Kawa), but we don't want to
get swamped by them. And preferably the Kawa list should be for
Kawa-specific questions, though it might be difficult for a beginner to
know which is which.
--
--Per Bothner
per@bothner.com http://per.bothner.com/