RFC open on newLISP documentation

Started by kazemori, November 28, 2003, 02:34:32 PM

Previous topic - Next topic


Manual correction?

Manual says

(sort '((3 4) "hi" 2.8 8 b)            => (8 2.8 "hi" b (3 4))

as stand should be

(sort '((3 4) "hi" 2.8 8 b))           => (8 2.8 "hi" b (3 4))


> (sort '((3 4) "hi" 2.8 8 b))

(2.8 8 "hi" b (3 4))


This means the bit about comparing different types viz

 If two expressions of different type get compared, then the lower type is sorted before the higher type in the following order:

Atoms:  nil, true, integer, float, string, symbol, primitive

is not correct as integer and float get compared as numbers not as

types. This also applies to the < discussed above.



Yes, the cast was missing in the code for %.

Following comment after reading http://mathforum.org/library/drmath/view/52343.html">http://mathforum.org/library/drmath/view/52343.html :

The modular function 'mod' for floats and '%' for integers work differently for negative numbers in newLISP compared to Excel. I am using the 'C' operator and the fp function fmod() (previously handcoded), which both work consistently returning :

(% -340 60)    => -40

(mod -340 60) => -40

They work as of the following definition, which I also added to the manual:

>> GNU libc documentation: >>

These functions compute the remainder from the division of numerator by denominator. Specifically, the return value is numerator - n * denominator, where n is the quotient of numerator divided by denominator, rounded towards zero to an integer. Thus, fmod (6.5, 2.3) returns 1.9, which is 6.5 minus 4.6.

The result has the same sign as the numerator and has magnitude less than the magnitude of the denominator.


A similar definition is also used in: http://www.opengroup.org/onlinepubs/007908799/xsh/fmod.html">http://www.opengroup.org/onlinepubs/007 ... /fmod.html">http://www.opengroup.org/onlinepubs/007908799/xsh/fmod.html



Also, I wonder what Eddie's opinion (aren't you a math person?) is on this one?



I have never worked with a mod for floating point numbers?

As for integers, this is a can of worms. Different language compilers (even different C compilers) don't even agree on x / y. If exactly one of x and y is negative, some will round down, -3 / 2 => -2, while others will round toward 0, -3 / 2 => -1. But rumor has it that / and % should agee to  x = y*(x/y) + x%y where y is not 0.



Here are some results of different languages.

GNU C gives

-340 % 60 => -40

Perl, Python, and Ruby give

-340 % 60 => 20

According to http://www.python.org/doc/current/ref/binary.html">http://www.python.org/doc/current/ref/binary.html the sign of x % y is the

same as its second argument. I would that is true for Perl and ruby as well.



GNU 'C' does the same for mod and %, always taking the remainder of the division towards zero versus towards the smaller (more left on the numbers axis) integer multiple of the denominator.

I will stay with theirs (GNU C) for now and have documented it in the manual. I find it more intuitive and easier to understand (of course this is very subjective). The Gnu 'C' version produces the same 'magnitude' for both signs =/-, while the other method produces two different numbers.

In any case the difference between the versions is only important when dealing with negative numbers. I wonder what tools like Mathematika or Matlab do and I also wonder what the 'deeper' mathematical meaning behind this is; perhaps its just that: viewing negative numbers as magnitudes versus point on a line starting at infinitive negative?



Tonight, I will dig up my number theory book and see what it has to say.



What's the latest newLISP Users Manual and Reference?  I've noticed a few more typos in v.7.4.0 but want to make sure I'm reading the latest revision before I post anything.


the latest one is always the latest in:


Both, the source and the Windows distribution have the manuals. The rc1,rc2,rc3 versions did not distinguish with version numbers inside, they say all: 7.4.0. So the stuff in rc3 is the latest.

I am about to post the final 7.4.0 but if you have some other typos today, I delay it until tomorrow.

In the release version of 7.4.0 you will have the copyright date changed to 2004, which will be the only thing indicating the difference between release candidate versions and the fnal release.



Just a few observations.  The page 7 and page 124 notes are the most important.

page 7: "When the DLL is loaded it looks for an ini.lsp file ..." -- should that be "an init.lsp file"?  If it should really be "ini.lsp", please emphasize (e.g., "yes, ini.lsp for the DLL instead of init.lsp").

page 124: syntax: (rename-file str-path) looks like (per the example) as if 'rename-file' should have two parameters.

page 145: in the paragraph describing 'trim': "... the space is assumes by default." should be "... the space character is assumed."


page 35: in the paragraph beginning "Calculations which result in value ..." -- the negation sign "-" in -2147483648 appears on a line by itself which can be confusing.  Is there a way to force it to move with the body of the number to the next line?


Thanks for the corrections Sam, I have put tags around the numbers, that will hopefully keep the sign with the number during PDF conversion.



page 88: the syntax for 'list' should have a closing parenthesis.


Thanks to all of you for helping to move newLISP forward a big step. Release 7.4.0 is available at http://newlisp.org">http://newlisp.org and http://sourceforge.net/projects/newlisp">http://sourceforge.net/projects/newlisp



This is late, I know, but maybe for the next update.

page 59: directory section: The last sentence should be followed by an example such as (directory "c:/").