What should the above return?
CLHS for SATISFIES says that
(typep x '(satisfies p)) is equivalent to (if (p x) t nil)
In that case (typep 'foo '(satisfies evenp)) will signal an error.
Maybe what was meant was
(if (ignore-errors (p x)) t nil)
??
--
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
We're too busy mopping the floor to turn off the faucet.
In article <··············@loiso.podval.org>,
Sam Steingold <···@gnu.org> wrote:
>What should the above return?
>CLHS for SATISFIES says that
> (typep x '(satisfies p)) is equivalent to (if (p x) t nil)
>In that case (typep 'foo '(satisfies evenp)) will signal an error.
I think it should.
>Maybe what was meant was
> (if (ignore-errors (p x)) t nil)
>??
No, if you want a type for even numbers, you should write:
(typep x '(and number (satisfies evenp)))
or
(typep x '(satisfied (lambda (x) (and (numberp x) (evenp x)))))
--
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin <······@genuity.net> writes:
> No, if you want a type for even numbers, you should write:
>
> (typep x '(and number (satisfies evenp)))
>
> or
>
> (typep x '(satisfied (lambda (x) (and (numberp x) (evenp x)))))
Huh? I can't find 'satisfied' in the CLHS and and the 'satisfies'
predicate only takes a symbol. What did I miss?
-Peter
--
Peter Seibel
·····@javamonkey.com
In article <··············@localhost.localdomain>,
Peter Seibel <·····@javamonkey.com> wrote:
>Barry Margolin <······@genuity.net> writes:
>
>> No, if you want a type for even numbers, you should write:
>>
>> (typep x '(and number (satisfies evenp)))
>>
>> or
>>
>> (typep x '(satisfied (lambda (x) (and (numberp x) (evenp x)))))
>
>Huh? I can't find 'satisfied' in the CLHS and and the 'satisfies'
>predicate only takes a symbol. What did I miss?
A typo and my mistake.
--
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin <······@genuity.net> writes:
> In article <··············@loiso.podval.org>,
> Sam Steingold <···@gnu.org> wrote:
> >What should the above return?
> >CLHS for SATISFIES says that
> > (typep x '(satisfies p)) is equivalent to (if (p x) t nil)
> >In that case (typep 'foo '(satisfies evenp)) will signal an error.
>
> I think it should.
FWIW, I agree with Barry. SATISFIES is documented to call the predicate.
The argument x is unconstrained. Therefore, the predicate must be a
universal predicate. If you have foreknowledge that X is always a number,
you can safely use EVENP, but not otherwise. No, it doesn't say this
explicitly anywhere, but I think this is all a logical consequence of what
is said.