Small observation re. (gt0 X) and ( X 0)

2013-11-15 Thread Jon Kleiser

Hi,

If you read the docs carefully, you may know that (gt0 X) and ( X 0) 
are NOT equivalent. This is my small observation today:


 X:1   T
---
(gt0 X) - 1   NIL

( X 0) - T   T

Have a nice weekend!

/Jon
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Small observation re. (gt0 X) and ( X 0)

2013-11-15 Thread Thorsten Jolitz
Jon Kleiser jon.klei...@usit.uio.no
writes:

Hi Jon,

 If you read the docs carefully, you may know that (gt0 X) and ( X 0)
 are NOT equivalent. This is my small observation today:

  X:1   T
 ---
 (gt0 X) - 1   NIL

 ( X 0) - T   T

 Have a nice weekend!

Surprising at first, but plausible after reading the docs. Thanks for
the tip!

-- 
cheers,
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Small observation re. (gt0 X) and ( X 0)

2013-11-15 Thread Alexander Burger
Hi Jon,

 If you read the docs carefully, you may know that (gt0 X) and ( X
 0) are NOT equivalent. This is my small observation today:
 
  X:1   T
 ---
 (gt0 X) - 1   NIL
 
 ( X 0) - T   T

Yes, very true. Thanks for reminding about it!

This is in fact the intended behavior. Perhaps I should add some
explanation.

1. '' is a function for general comparisons, not only for numbers but
   for any data type. As described in

  http://software-lab.de/doc/ref.html#cmp

   all data in PicoLisp have a well-defined ordinal relationship. This
   defines that

  NIL  numbers  symbols  lists  T

   As a result, both '1' and 'T' are greater than '0'.


2. 'gt0', on the other hand, is a predicate for numbers greater zero:

  http://software-lab.de/doc/refG.html

   Thus, it returns the numeric argument for '1', and 'NIL' for any non-
   numeric argument.

BTW, eeturning the argument itself instead of simply 'T' is very
convenient in many situations, e.g.

   (while (gt0 (foo))  # No need to store the result of (foo)
  (bar @) )# in a local variable


 Have a nice weekend!

Thanks, you too!
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe