The 9.4.0 newLISP manual
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
"integer" appears to be alias for "int" but is not documented in manual.
On the other side, "int?" is not defined as predicate, but "integer?" is.
I think it is the best to define both as aliases - "int" and "integer"; "int?" and "integer?" and also to document both. (Such aliases, short and long seem to be good practice to me.)
On the other side, "int?" is not defined as predicate, but "integer?" is.
I think it is the best to define both as aliases - "int" and "integer"; "int?" and "integer?" and also to document both. (Such aliases, short and long seem to be good practice to me.)
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
chm just is so easy to click on actualy and Voila you have a nice windowed
manual that runs on everything that has windows on it..
But i agree chm is from the OS2 days and its time for Microsoft to invent
their own stuff for once ;-)
I think Ill continue with porting the the Newlisp manual then to my JAVA
manual viewer by use of GS...(always a pleasure to use domestic tools ;-)
manual that runs on everything that has windows on it..
But i agree chm is from the OS2 days and its time for Microsoft to invent
their own stuff for once ;-)
I think Ill continue with porting the the Newlisp manual then to my JAVA
manual viewer by use of GS...(always a pleasure to use domestic tools ;-)
-- (define? (Cornflakes))
For release 10.0
perhpas the left pane index could get a little more extention?
! +-*/% Ab Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Ma Me Na Ne No O Pa Q Ra Reg Sa Sh St T U W X
more function now exist and this small index jumps over functions...
Not realy an issue but would walking through the manual a little more
smooth...
! +-*/% Ab An Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Lo Ma Me Na Ne Ni No Nu O Pa Pe Pi Q Ra Re Ro Sa Se Si Sg Sh So St Sy Ta Ti Un Up Ut Wa Wr X Ze
perhpas the left pane index could get a little more extention?
! +-*/% Ab Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Ma Me Na Ne No O Pa Q Ra Reg Sa Sh St T U W X
more function now exist and this small index jumps over functions...
Not realy an issue but would walking through the manual a little more
smooth...
! +-*/% Ab An Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Lo Ma Me Na Ne Ni No Nu O Pa Pe Pi Q Ra Re Ro Sa Se Si Sg Sh So St Sy Ta Ti Un Up Ut Wa Wr X Ze
-- (define? (Cornflakes))
For release 10.0
another document extention...
Could the Chapters listed on the left frame ->
List processing, flow control and integer arithmetic
String and conversion functions
Floating point math and special functions
Matrix functions
Array functions
..
..
Also "be" a link that points to the description of these...
another document extention...
Could the Chapters listed on the left frame ->
List processing, flow control and integer arithmetic
String and conversion functions
Floating point math and special functions
Matrix functions
Array functions
..
..
Also "be" a link that points to the description of these...
-- (define? (Cornflakes))
9.9.9.3
Manual states, which does not work anymore due to inc/dec changes->
Functions with memory
A default function can update the lexically isolated static variables contained inside its namespace:
;; a function with memory
(define (Gen:Gen x)
(if Gen:acc
(inc 'Gen:acc x)
(set 'Gen:acc x)))
(Gen 1) → 1
(Gen 1) → 2
(Gen 2) → 4
(Gen 3) → 7
gen:acc → 7
Manual states, which does not work anymore due to inc/dec changes->
Functions with memory
A default function can update the lexically isolated static variables contained inside its namespace:
;; a function with memory
(define (Gen:Gen x)
(if Gen:acc
(inc 'Gen:acc x)
(set 'Gen:acc x)))
(Gen 1) → 1
(Gen 1) → 2
(Gen 2) → 4
(Gen 3) → 7
gen:acc → 7
-- (define? (Cornflakes))
init.conf.example has a wrong directory for lynx.
"lynx /usr/share/newlisp/doc/newlisp_manual.html#%s"
should be (according to the Makefile) ->
"lynx /usr/share/doc/newlisp/newlisp_manual.html#%s"
On the otherhand? You could change it with this ->
(but the html is very nice too)
;; --- command line help
(define-macro (help func-name)
(if (find func-name "|+*-") (push "\\" func-name))
(set 'html-text (join (find-all (format {(syntax: \(%s.*?)} (name func-name) )
(read-file "/usr/share/doc/newlisp/newlisp_manual.html")) "\n"))
(println (replace "<.*?>" html-text "" 0))
"" )
"lynx /usr/share/newlisp/doc/newlisp_manual.html#%s"
should be (according to the Makefile) ->
"lynx /usr/share/doc/newlisp/newlisp_manual.html#%s"
On the otherhand? You could change it with this ->
(but the html is very nice too)
;; --- command line help
(define-macro (help func-name)
(if (find func-name "|+*-") (push "\\" func-name))
(set 'html-text (join (find-all (format {(syntax: \(%s.*?)} (name func-name) )
(read-file "/usr/share/doc/newlisp/newlisp_manual.html")) "\n"))
(println (replace "<.*?>" html-text "" 0))
"" )
-- (define? (Cornflakes))
Errata:
http://newlisp.nfshost.com/downloads/de ... anual.html
A sneaky html / frames problem with this section in the manual:
---------
4. Functions in alphabetical order
! +-*/% Ab Ap As Ba Ca Cl Co Cu De Di Do En
Ex Fi Fl Ga Gl In La Li Ma Mu Net New Nt Pa
Pr Ra Rea Reg Sea Seq Sl St Sy Ti Tr Ut Wr
Appendix...
-------
When reading the newLISP manual in HTML format, no frames, clicking on any of the above links opens another (one) copy of newlisp_manual.html in my browser...
The problem is caused by the links being in the form:
when no parent frame is present...
So the links in newlisp_manual.html should be in this form:
Note: target="body" does not cause a problem when clicking these links from this section of the newlisp_manual.html in the frames version. That is, when the manual_frame.html page is used to view the manual.
---------
set-ref-all * <- uses asterisk instead of ! (exclamation point) as used by all other destructive functions
----------
-- xytroxon
http://newlisp.nfshost.com/downloads/de ... anual.html
A sneaky html / frames problem with this section in the manual:
---------
4. Functions in alphabetical order
! +-*/% Ab Ap As Ba Ca Cl Co Cu De Di Do En
Ex Fi Fl Ga Gl In La Li Ma Mu Net New Nt Pa
Pr Ra Rea Reg Sea Seq Sl St Sy Ti Tr Ut Wr
Appendix...
-------
When reading the newLISP manual in HTML format, no frames, clicking on any of the above links opens another (one) copy of newlisp_manual.html in my browser...
The problem is caused by the links being in the form:
Code: Select all
<a href="..." target="body">
So the links in newlisp_manual.html should be in this form:
Code: Select all
<a href="...">
---------
set-ref-all * <- uses asterisk instead of ! (exclamation point) as used by all other destructive functions
----------
-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
-- Let's Talk Lisp (c) 1976
Thanks for all the manual corrections. An updated version is available here:
http://www.newlisp.org/downloads/develo ... anual.html
http://www.newlisp.org/downloads/develo ... anual.html
according to the manual ->
A lambda list can be manipulated as a first-class object using any function that operates on lists:
(setf (double 1) '(mul 2 x)) → (lambda (x) (mul 2 x))
double → (lambda (x) (mul 2 x))
(double 123) → 246
But that gives ->
# No Symbol reference found!
A lambda list can be manipulated as a first-class object using any function that operates on lists:
(setf (double 1) '(mul 2 x)) → (lambda (x) (mul 2 x))
double → (lambda (x) (mul 2 x))
(double 123) → 246
But that gives ->
# No Symbol reference found!
-- (define? (Cornflakes))
The example in the manual is wrong, because '(double 1)' will be evaluated returning 2, its the ambiguity of implicit indexing versus function call, therefore 'nth' has to be used:
This is the correct example:
This is the correct example:
Code: Select all
(setf (nth 1 double) '(mul 2 x)) => (mul 2 x)
double => (lambda (x) (mul 2 x))
manual 9.9.95
Use the constant function (which works like set) to protect the symbol from subsequent alteration. Using the setq or setq function eliminates the need to quote the variable symbol.
should be ->
Use the constant function (which works like set) to protect the symbol from subsequent alteration. Using the setq or setf function eliminates the need to quote the variable symbol.
(setq should be setf, the link is oke though...)
should be ->
Use the constant function (which works like set) to protect the symbol from subsequent alteration. Using the setq or setf function eliminates the need to quote the variable symbol.
(setq should be setf, the link is oke though...)
-- (define? (Cornflakes))
9.9.95 typo...
syntax: (copy exp)
Make a copy from evaluating expression in exp. Some built-in functions are destructive, changing the original contents of a list, array or string they are working on. With copy their behvior can be made non-destructive.
should be "behavior"
syntax: (copy exp)
Make a copy from evaluating expression in exp. Some built-in functions are destructive, changing the original contents of a list, array or string they are working on. With copy their behvior can be made non-destructive.
should be "behavior"
-- (define? (Cornflakes))
Add an example or two to EXEC?
I was looking at some functions in the manual and noted EXEC enables launching a process, such as another newlisp process (among others), and passing a command to it. For example,
For those that use newLISP quite a lot, I'm sure that the text in the manual is sufficient. But for new folks, or those that aren't hard-core users (I'm in that group), a couple of examples of code that really works would be very helpful.
I suspect that this could be useful if a blocking function needs to be called. So rather than calling the blocking function in the first newlisp process, launch a second newlisp process and call the blocking function and somehow capture the result. It is not clear to me how to capture the result from the second process. To where does the result go? How to determine if the result is availalble (maybe run a timer and check for wherever the result goes being true? Or somehow check for the final return value of true?)
Code: Select all
(exec "newlisp" "(+ 3 4)" ) -->
7
true
I suspect that this could be useful if a blocking function needs to be called. So rather than calling the blocking function in the first newlisp process, launch a second newlisp process and call the blocking function and somehow capture the result. It is not clear to me how to capture the result from the second process. To where does the result go? How to determine if the result is availalble (maybe run a timer and check for wherever the result goes being true? Or somehow check for the final return value of true?)
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2
"Getting Started with Erlang" version 5.6.2
Note that when using the second syntax of 'exec' feeding stdin to the process. Only 'true' or 'nil' is returned. The '7' you are seeing is only stdout of the process showing up in the your console terminal. Only when not feeding stdin, the output of the process is collected and comes back in a list:
For what you are suggesting 'process' with the pipes option may be the better solution, because you can set up a non-blocking bidirectional communication and use 'peek' to check if something is ready on the input pipe:
Look also into 'net-eval' which allows you to distribute processes on different machines on a network. Its blocking but can also be event driven when a node has a result ready.
If you are on Mac OS X, Linux or other Unix you should also look into newLISP's Cilk API with the functions 'spawn', 'sync' etc.
Code: Select all
> (exec "newlisp -e '(+ 3 4)'" )
("7")
>
Code: Select all
> (map set '(myin nlout) (pipe))
(3 4)
> (map set '(nlin myout) (pipe))
(5 6)
> (process "/usr/bin/newlisp" nlin nlout)
15763
> (write-buffer myout "(+ 3 4)\n")
8
> (peek myin)
2
> (read-line myin)
"7"
> (write-buffer myout "(exit)")
6
> (peek myin)
0
>
If you are on Mac OS X, Linux or other Unix you should also look into newLISP's Cilk API with the functions 'spawn', 'sync' etc.
Thanks for the explanation.
This code doesn't work for me (Windows XP pro, newLISP 9.3.0)
Here is the result I get
(There are probably more spaces betwee the + and \\, but I didn't count them all.)
This code doesn't work for me (Windows XP pro, newLISP 9.3.0)
Code: Select all
> (exec "newlisp -e '(+ 3 4)'" )
("7")
>
Code: Select all
("" "missing parenthesis : \"...'(+ \\168\225\\\"\"")
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2
"Getting Started with Erlang" version 5.6.2
Try this:
Quotes are not permitted on Windows as token delimiters on the command line, using curly braces as the outer string delimiters you can use double quotes inside.
ps: redundant parentheses removed
Code: Select all
> (exec {newlisp -e "(+ 3 4)"})
("7")
>
ps: redundant parentheses removed
Last edited by Lutz on Fri Nov 28, 2008 1:42 am, edited 1 time in total.