On Wed, Oct 22, 2008 at 4:49 PM, Waldek Hebisch wrote:
>
> ATM I have no strong opinion about 'one? ...' and 'zero? ...'.
> However, they have really nothing to do with CCL -- they are
> Spad functions which for some domains may be given some
> special Lisp implementation.
Yes. For example:
algebra/integer.spad.pamphlet:-- one? x == ONEP(x)$Lisp
algebra/constant.spad.pamphlet:-- one? a == one? numer a and one? denom a
algebra/poly.spad.pamphlet:-- one?(p):Boolean == not empty? p and
(empty? rest p and zero? first(p).k and one? first(p).c)
algebra/si.spad.pamphlet:-- one?(x) == ONEP(x)$Lisp
"The definition of {\bf one?} has been rewritten
as it relies on calling {\bf ONEP} which is a function specific
to Codemist Common Lisp but is not defined in Common Lisp."
There are many other cases in the source.
> Both are just special case of eqality.
I do not agree. It is quite conceivable to me that there could be a
domain in which equality is not defined (e.g. it might not transitive)
but in which it makes good sense to be able to test for specific
values.
> 'one? ...' and 'zero? ...' in principle may be slightly more efficient than
> general equality because frequently 0 and 1 have very special
> representation. Also, 0 and 1 sometimes are special cases for
> equality, so we may get deeper recursion (and there is some
> risk of infinite loops).
Yes. Consider the code that is generated by
one?(x:X):Boolean == x = 1
We must call both 'one()$X' and the function =:(X,X)->Boolean, where
one function call would have sufficed. And when representations are
complicated, this effect can multiply.
> OTOH using just equality mathematically looks cleaner.
>
In foundational mathematics it is very common to distinguish 0 and 1
as special cases. Equality on the other hand is a much more
complicated subject.
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---