I've often thought it would be good to learn Lisp and so I'm trying newLISP (despite what some purists might argue).
I have problem already. In the following code I tests whether 'j' is a list, and if so I ask for a count of it and print the result. Every time I run it, it fails with a "ERR: list expected in function count : nil".
c:tempdata is a text file containing crlf-delimited lines of two tab-delimited items.
Here's the code
(dolist
(i
(parse
(read-file "c:\temp\data") "rn"
)
)
(begin
(set 'j (reverse (parse i "t")))
(print j "n")
(when (list? j)
(print (count j) "n")
)
(set 'k (j 0))
(set 'l (j 1))
)
)
What is my non-Lisp mind not seeing?
Kind regards,
Bruce.
P.S. Is there a way of assigning (j 0) to k and (j 1) to l in one statement, i.e. does newLISP permit double (or more) assignment?
Oops, answered the question here:
http://www.alh.net/newlisp/phpbb/viewtopic.php?t=2727
And you seems to want length instead of count (which takes 2 lists as arguments)
(dolist
(i
(parse
(read-file "C:\Programme\newlisp\Test1.txt") "rn"
)
)
(begin
(set 'j (reverse (parse i "t")))
(print j "n")
(when (list? j)
(print (length j) "n")
)
(if (>(length j)0)(set 'k (j 0) 'l (j 1)))
)
)
Quote from: "HPW"
And you seems to want length instead of count (which takes 2 lists as arguments)
Umm ... er ... yes, I did want (length); finally read the friendly manual. Thanks.
Kind regards,
Bruce.