Manual Notes 10.2.1

Notices and updates
Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Manual Notes 10.2.1

Post by Sammo »

In the documentation for 'explode', ...

Code: Select all

; omit last chunk if too short
(explode '(a b c d e f g h) 2 true)  → ((a b) (c d) (e f))
should be:

Code: Select all

; omit last chunk if too short
(explode '(a b c d e f g) 2 true)  → ((a b) (c d) (e f))

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

In newlisp_index.html,
plese add "explode" to "List processing, flow control and integer arithmetic".


And,

pretty-print

(pretty-print 90 "\t") → (90 "\t")
(pretty-print 90 "\t") → (90 "\t" "%1.10g")

(pretty-print 100) → (100 "\t")
(pretty-print 100) → (100 "\t" "%1.10g")

The first example reports the default settings of 80 for the maximum line length and a TAB character for indenting.
The first example reports the default settings of 80 for the maximum line length and a space character for indenting.

The second example changes the line length to 90 and the indent to a TAB character.

Isn't the second example necessary ?


print

\xhh where hh is a hexadecimal ASCII code between 00 and FF

Unless undocumented, I hope to add this or a more appropriate representation.


pv

The future value num-pmt is assumed to be 0.0 if omitted. If payment is at the end of the period,
The future value num-fv is assumed to be 0.0 if omitted. If payment is at the end of the period,


read-expr

read-expr parses the first expressions it finds in str-source and an returns the translated expression without evaluating it.
read-expr parses the first expressions it finds in str-source and returns the translated expression without evaluating it.

Maybe.


read-utf8

The fucntion returns and integer value which can be converted to a displayable UTF-8 character string using the char function.
The fucntion returns integer value which can be converted to a displayable UTF-8 character string using the char function.

Maybe.


ref

By default, ref checks if expressions are equal. With func-compare, more complex comparison functions can be defined.

The comparison function can be a previously defined function.
Note that the comparison function always takes two arguments,
even if only the second argument is used
inside the function.


From ref-all.
Aren't these necessary ?


ref-all

(as in the example using long?).
(as in the example using is-long?).


send

This way the non-blocking message function can be made blocking until it succeeds:
This way, the non-blocking message function can be made blocking until it succeeds:

Maybe.

After sending the three messages the statement:
After sending the three messages, the statement:

Maybe.

(set 'finished true))
(set 'finished true)


set-ref-all

When evaluating (foo data), the list in db:db will be passed by reference and <tt>set-ref-all</tt> will make the changes on the original, not on a copy of db:db.
When evaluating (foo db), the list in db:db will be passed by reference and <tt>set-ref-all</tt> will make the changes on the original, not on a copy of db:db.


sgn

nil is returned.
If exp-2 is not specified, nil is returned with zero and,
if exp-3 is not specified, nil is returned with positive number.


Or more appropriate representations.


share

the return value will be any constant or expression (since v.10.1.0)
written into the memory previously.
The return value will be any constant or expression (since v.10.1.0)
written into the memory previously.

Maybe.


spawn

The example also shows how code written for the Cilk API will work under Win32, too, with spawn simply working as a set and sync just returning an empty list.
The example also shows how code written for the Cilk API will work under Win32, too, with spawn simply working as a set and sync just returning an empty list or true.

Maybe.


sys-info

Eight integers report the following status:
Ten integers report the following status:

Maybe unless eight means 8-bits integer.


timer

Option 3 is a combination of both called profiling time.
Option 2 is a combination of both called profiling time.

This can be used to program timelines or schedules.
This can be used to program time lines or schedules.
or
This can be used to program timeliness or schedules.

Maybe.


true?

Since version 9.1, true? behaves like if and rejects the empty list ()
Since version 9.1, true? behaves like if and rejects the empty list ().


until

Evaluates the condition in exp-condition body.
Evaluates the condition in exp-condition.


write-char

(while (set 'chr (read-file in-file))
(while (set 'chr (read-char in-file))


xml-parse

As the database in example.xml only contains data, we can suppress whitespace and comments with option (+ 1 3):
As the database in example.xml only contains data, we can suppress whitespace and comments with option (+ 1 4):
or
As the database in example.xml only contains data, we can suppress whitespace, empty attribute and comments with option (+ 1 2 4):

Using xml-type-tags to suppress all XML-type tags-along with the option numbers 1, 4, 8, and 16-SXML formatted output can be generated:
Using xml-type-tags to suppress all XML-type tags-along with the option numbers 1, 2, 4, 8, and 16-SXML formatted output can be generated:

(xml-parse (read-file "example.xml") (+ 1 2 8) MAIN xml-callback)
(set 'example-xml (read-file "example.xml"))
(xml-parse example-xml (+ 1 2 8) MAIN xml-callback)


Maybe, or new xml-callback.


Some in the above-writing may be unnecessary.


By the way,
I finished a Japanese translation of the "4.Functions in alphabetical order" of the "Function Reference", but v.10.1.7.

It is possible to download it from the following URL.

http://cid-23a9a25e1aec3626.skydrive.li ... -10107.zip

Next, I will try to translate the current version.

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

1. Syntax of symbol variables and numbers
Symbols for variable names
Numbers


As described above, scientific notation starts with a floating point number
As described below, scientific notation starts with a floating point number

Maybe.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thank you very much Johu, an updated revision 5 is online here:

http://www.newlisp.org/downloads/newlisp_manual.html

ps: I also have linked your blog from this page: http://www.newlisp.org/index.cgi?Code_Contributions and hope I got the title right?

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

Thank you very much, Lutz.

My blog title is OK, but a link is the following:

http://johu02.spaces.live.com/?_c11_Blo ... cat%3dLISP


This is the part of lisp in my blog.

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Re: Manual Notes 10.2.1

Post by xytroxon »

Lutz wrote:Thank you very much Johu, an updated revision 5 is online here:

http://www.newlisp.org/downloads/newlisp_manual.html
The xhtml parsing routine (per the post below) now fails...

http://newlispfanclub.alh.net/forum/vie ... 931#p17931

==========

newLISP REPL - (Read Execute Print Loop). Press Ctrl-Z to exit.
newLISP v.10.2.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (xml-type-tags nil nil nil nil)
(nil nil nil nil)

> (ref-all '(h1 *) (xml-parse (read-file "./newlisp_manual.html") 15) match true)

ERR: list expected : nil
>

-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Manual Notes 10.2.1

Post by cormullion »

Code: Select all

(xml-error)
;-> ("closing tag doesn't match" 572782)
I think the current version no longer "validates"... But it could be anything... :(

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

repaired now:

http://www.newlisp.org/downloads/newlisp_manual.html

On Mac OS X, to find these things, use:

Code: Select all

tidy -utf8 -xml newlisp_manual.html > /dev/null

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Re: Manual Notes 10.2.1

Post by xytroxon »

After three hours, I think I narrowed it down to two sections...

<b>></b> needs to be changed to <b>></b>

Code: Select all

An evaluated context (no quote) can be given as an argument:

> (context 'FOO)
FOO
FOO> (context MAIN)
MAIN
> (set 'old FOO)
FOO
> (context 'BAR)
BAR
BAR> (context MAIN:old)
FOO
FOO>
And -> needs to be changed to ->

Code: Select all

Running above example produces the following output:

pid:53181->47  pid:53180->61  pid:53179->75  pid:53178->39  pid:53177->3
pid:53181->59  pid:53180->12  pid:53179->20  pid:53178->77  pid:53177->47
pid:53181->6   pid:53180->56  pid:53179->96  pid:53178->78  pid:53177->18
-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

johnd
Posts: 18
Joined: Mon May 09, 2005 7:54 pm
Location: San Francisco, CA

Re: Manual Notes 10.2.1

Post by johnd »

The manual entry for "sync" should not precede "sym". It should follow the entry for "symbols".

John

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

In newlisp_index.html

Floating point math and special functions

<a href="newlisp_manual.html#gammaln" target="body">atan</a><br />
<a href="newlisp_manual.html#gammaln" target="body">gammaln</a><br />

There are not array, array-list, uuid.


Array functions

There is not slice.


Input/output and file operations

There is not current-line.


Reflection and customization

There is not last-error


System functions

There is not catch.


newLISP internals API
There is not read-expr.

I compared newlisp_index.html with "Functions in groups" in newlisp_manual.htm

And,

"Functions in groups" in newlisp_manual.htm

Floating point math and special functions
There is not tan.

Pattern matching
There are not ref, ref-all.

System functions
There are not callback, read-expr, sym.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thanks Johnd and Johu, a new version rev-9 is online:

http://www.newlisp.org/downloads/manual_frame.html

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

3. Functions in groups
List processing, flow control and integer arithmetic


There are not if-not and pop-assoc.

do-until
repeats evaluation of an expression until the condition is met
repeats evaluation of a block of statements until the condition is met

do-while
repeats evaluation of an expression while the condition is true
repeats evaluation of a block of statements while the condition is true

self
Acccesses the target object inside a FOOP method
Accesses the target object inside a FOOP method

unless
evaluates an expression conditionally
evaluates a block of statements conditionally

while
repeats evaluation of an expression while the condition is true
repeats evaluation of a block of statements while the condition is true


String and conversion functions

There are not dostring and find-all in newlisp_index.html.

member
finds a list or string member
finds a member of a list or string

(from List processing, flow control and integer arithmetic)

name
returns the name of a symbol or its context as a string
This function is deprecated, use term instead

Or delete?


Pattern matching

<a name="pattern"></a>
<h3>Pattern matching</h3>
<table border="0" cellpadding="1" width="95%" align="center" summary="Time and date functions">
<table border="0" cellpadding="1" width="95%" align="center" summary="Pattern matching">


Input/output and file operations

read-utf8
reads UTF-8 character from a file
reads an UTF-8 character from a file

Maybe.


Reflection

term
returns the term part of a symbol or its context as a string
returns the term part of a symbol without the context prefix as a string



4. Functions in alphabetical order

--
Without the optional argument in num-2,
Without the optional argument in num,

<<, >>
When int-1 is the only argument << and >> shift by one bit.
When int-1 is the only argument, << and >> shift by one bit.

Maybe.

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

I have one question.

4. Functions in alphabetical order
+, -, *, / ,%
For floating point values that evaluate to NaN (Not a Number), both +INF and -INF are treated as 0 (zero).
I think that this sentence means the following:

Code: Select all

> (sqrt -1)
nan
> (+ (sqrt -1))
0
> (mul 1e308 10)
inf
> (+ (mul 1e308 10))
9223372036854775807
> (mul -1e308 10)
-inf
> (+ (mul -1e308 10))
9223372036854775807
Is it right ?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Yes, this is how NaN and +/- Inf and mixing with integer arithmetic should behave. The rules are outlined in this file:

http://www.newlisp.org/syntax.cgi?code/qa-float.lsp.txt

also in the source distribution at newlisp-x.x.x/qa-specific-test/qa-float

... but I see negative Inf is not treated correctly on Win32 but fine on UNIX and not tested in qa-float.

ps: this is fixed for Win32 in v.10.2.4

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

I have some suggestion.

+, -, *, / ,%

For floating point values that evaluate to <tt>NaN</tt> (Not a Number),
both <tt>+INF</tt> and <tt>-INF</tt> are treated as <tt>0</tt> (zero).


Floating point values that evaluate to NaN is treated as <tt>0</tt> (zero),
and both <tt>+INF</tt> and <tt>-INF</tt> are treated as the maximum (<tt>9,223,372,036,854,775,807</tt>) integer values.


Because the misunderstanding may be carused.


case

The result of the last match is returned as the result for the entire case expression.
The result of the last expression in body is returned as the result for the entire case expression.

I think that "the last match" may cause a misunderstanding.


char

The empty string or a binary zero character return nil, but (char 0) will return "\000".
The empty string return nil, but (char nil) will return "\000".

Because (char "\000") return 0 (zero).

Given an integer argument, char returns a string containing the ASCII character with value int.
Given an integer argument, char returns a string containing either the ASCII character with value int or the character escaped with a \ (backslash) for a three-digit ASCII number.

It might be unnecessary.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thanks Johu.

Note, that the integer conversion of -Inf will return the max negative integer starting 10.2.4 on Win32. On other OS, this was already the case.

There will be a new development release (source only) this weekend v.10.2.4.

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

clean
(with the list option).
(with the list mode).

from difference.


intersect
In the second syntax,
In the second syntax, intersect works in list mode.

from difference.


difine-macro

A third possibility is to refer to passed parameters using args:
A second possibility is to refer to passed parameters using args:

maybe.

<a href="#dolust">dolist</a> as a <em>break condition</em>
<a href="#dolist">dolist</a> as a <em>break condition</em>


delete

This mode can be used to delete namespace hashes and in object systems,
This mode can be used to delete namespace hashes in object systems,

maybe.

and bug ?

Code: Select all

newLISP v.10.2.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (set 'lst '(a b aVar c d))
(a b aVar c d)
> (delete 'aVar true)
true
> lst
(a b nil c d)
> 
also Linux-version.


det

If the matrix is singular and float-pivot is not specified nil is returned.
If the matrix is singular and float-pivot is not specified, nil is returned.

maybe.


device

int is an I/O device number,
int-handle is an I/O device number,

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thanks Johu, I will take care of this in the next development release.

ps: as of now back on US Eastern Time.

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Re: Manual Notes 10.2.1

Post by Kazimir Majorinc »

constant !

(constant sym-1 exp-1 [sym-2 exp-2 ... ]) => (constant sym-1 [exp1 [sym-2 [exp-2 ... ]]])

because (constant 'x), (constant 'x 1 'y), ... are allowed ...

---

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

find
Find an expression in a list


If the first argument is a string, a regular expression option can be specified with int-regex-option and optionally an int-offset parameter.
If the first argument is a string, a regular expression option can be specified with int-regex-option parameter.

Because,
syntax: (find exp-key list [func-compare | int-regex-option])

first

In the second syntax,
In the third syntax,

Maybe.


format

The w represents the width field. Data is right-aligned, except when preceded by a minus sign, in which case it is left-aligned. When preceded by a zero, the unused space is filled with leading zeroes. The width field is optional and serves all data types.

The p represents the precision number of decimals (floating point only) or strings and is separated from the width field by a period. Precision is optional. If preceded by a + (plus sign), positive numbers are displayed with a +. When using the precision field on strings, the number of characters displayed is limited to the number in p.


The w represents the width field. Data is right-aligned, except when preceded by a minus sign, in which case it is left-aligned. If preceded by a + (plus sign), positive numbers are displayed with a +. When preceded by a zero, the unused space is filled with leading zeroes. The width field is optional and serves all data types.

The p represents the precision number of decimals (floating point only) or strings and is separated from the width field by a period. Precision is optional. When using the precision field on strings, the number of characters displayed is limited to the number in p.

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

inf?

See also A to check is a floating point number is valid.
See also A to check if a floating point number is valid.


let

See also letn for an incremental or nested form of let.
See also letn for an incremental or nested form of let and local for initializing to nil.

Maybe, better ?


letex

This functions combines let and expand to expand local variables into an expression before evaluating it.
This function combines let and expand to expand local variables into an expression before evaluating it.

But, I saw sometimes "This functions" in other web sites.
This writing may be used commonly ?


map

Arguments missing in other argument lists cause an error message.
Arguments missing in other argument lists are assumed nil or the empty list ().

Becasue,

Code: Select all

newLISP v.10.2.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (map (fn (x y z) (list $idx x y z)) '(a b c) '(1 2) '(A B C D E))
((0 a 1 A) (1 b 2 B) (2 c nil nil))
> (map list '(a b c) '(1 2) '(A B C D E))
((a 1 A) (b 2 B) (c))
> 

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thanks Johu.

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Manual Notes 10.2.1

Post by johu »

Last time, I made a mistake in inf?.

inf?
See also NaN? to check is a floating point number is valid.
See also NaN? to check if a floating point number is valid.


And, this time.

now

Am optional list-index in int-index makes now return a specific member in the result list.
An optional list-index in int-index makes now return a specific member in the result list.

The resolution of the microsecond field
depends on the operating system and platform. On some platforms,
the last three digits of the <tt>microseconds</tt> field are always
<tt>0</tt> (zero).
The resolution of the <tt>microsecond</tt> field
depends on the operating system and platform. On some platforms,
the last three digits of the <tt>microsecond</tt> field are always
<tt>0</tt> (zero).


parse-date

The function parse-date returns the number of seconds passed since January 1, 1900.
The function parse-date returns the number of seconds passed since January 1, 1970 from December 14, 1901 until January 19, 2038.

Because,

Code: Select all

newLISP v.10.2.1 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (parse-date "2007.1.3" "%Y.%m.%d")
1167782400
> (parse-date "January 10, 07" "%B %d, %y")
1168387200
> (parse-date "1970.1.1" "%Y.%m.%d")
0
> (parse-date "1900.1.1" "%Y.%m.%d")
2085892096
> (parse-date "1901.12.13" "%Y.%m.%d")
2147408896
> (parse-date "1901.12.14" "%Y.%m.%d")
-2147472000
> (parse-date "2038.1.19" "%Y.%m.%d")
2147472000
> (parse-date "2038.1.20" "%Y.%m.%d")
-2147408896
> 
Probably,
the function parse-date returns a signed 32-bit long number,
But the function date-value returns an unsigned 32-bit long number.
So, it can be used until February 6, 2106.
> (date-value 2106 2 6)
4294944000
> (date-value 2106 2 7)
63104
>

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Manual Notes 10.2.1

Post by Lutz »

Thanks Johu, changes are online in rev-15:

http://www.newlisp.org/downloads/newlisp_manual.html

Locked