Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - lyl

#16
newLISP and the O.S. / Re: hpwNLAutoItDll released
July 31, 2019, 08:00:44 PM
when :
(load "hpwAutoIt.lsp")
 error message given:ERR: problem loading library in function import : "AutoItDLL.dll"

Why?



Ps:

newlisp v10.7.4, win7

AutoItDLL.dll, hpwAutoIt.lsp, newlisp.exe are in the same folder.
#17
(setq a '(1 2 3)) ;; This list can not be evaled
(setq b '(1 a)) ;; This list can be evaled, (eval b) --> (2 3)
(setq c '(+ 1 2)) ;; This list can be evaled, (eval c) --> 3


My quesstion is:

Is there an universal method to determine whether a list can be evaluated or not?



In the following example:
(setq a '(1 2 3))
(setq d '((1 a) (3 4)))
(define (f lst) (+ (last lst) 1))
(f (d 0)) ;;->ERR: value expected : a
          ;;  called from user function (f (d 0))
(f a) ;;-> 4


The error in (f (d 0)) can be corrected by (f (eval (d 0))).

But "eval" can not used like this: (f (eval a)).

As the structure of the argument "lst" can not be forseen, is there a way to determine whether a list can be evaluated or not?
#18
Yet, is there a better way to evaluate elements in hash-table when constructing hash-table, as like the comma expression in common lisp?
#19
Since l in my example has the same structure as the initializer expressions of let, why does not it work in :

(setq l '((a 1) (b 2)))

(let l (+ a b)) ?
#20
I think the following two examples of using "let" say the same thing but they get different result:

Example #1:
(setq l '((a 1) (b 2)))
(let l (+ a b)) ;; ERR: invalid let parameter list in function let : l

Example #2:
(let ((a 1) (b 2)) (+ a b)) ;; get 3 as expected

Why is the first example a wrong way using "let"? And is there a way to give initializer expressions of "let" with a predefined list as shown in the first example?
#21
Sorry, I didn't make my question clear.

What I want is not the result of each first element evaluation. I want to get a easy way to construct "mytable" from
'(((char "a") "a: choiceA" (+ 0 101))  ((char "b") "b: choiceB" (+ 0 102)))
to
'((97 "a: choiceA" (+ 0 101)) (98 "b: choiceB" (+ 0 102)))
#22
I construct a hash-table like this:
(setq mytable '(
     ((char "a") "a: choiceA" (+ 0 101))
     ((char "b") "b: choiceB" (+ 0 102))
     ))

In this example, I want the first element of each sublist to be evaluated while other elements not. That is to say, (char "a") should be 97, (char "b") should be 98.

Or, in common, how to  partially evaluate elements in a hash-table? Is there an easy to achieve this?
#23
Many thanks @ ralph.ronnquist for your solution!!

Though I can't understand why the case term is designed not to evaluate the branch keys. Anyone knows the reason?
#24
I construct the following function by the primitive "case"
(define (f obj a da b db)
  (case obj
(a da)
(b db)
(true obj)
))
(f 1 1 "a" 2 "b") ;;=> I get 1, but what I want is "a".


What is the cause? And how to get what I want in the above code by the use of "case"?
#25
Anything else we might add? / Re: case design
June 05, 2019, 01:42:55 AM
I meet this problem too, and has been waiting for answer!
#26
Thank you @HPW. My description in the post made my query not clear. I just modified it. Would you please have look at it?
#27
QuoteSource code and the newLISP executable can be linked together to build a self-contained application by using the -x command line flag.

My script file(named "0.lsp" in Windows sys) contains the following code at the begining:
(load "1.lsp")
(load "2.lsp")

So in this condition how to use "newlisp -x" to build my application which can be used independently in any directory?

I mean, linking all files(0.lsp, 1.lsp, 2.lsp) into a .exe file. Thus, this only one .exe file can work anywhere without any other file to support it.
#28
Perfect explanation! I learn a lot. Many thanks!
#29
I want to run the dos command in win7 console by newlisp "exec" to clear secreen like this:
(exec "cls")
but fails with a feedback ("f").

Why? And how to deal with this?



PS: Also (exec "color 0b") does not work.
#30
I think the following two examples say the same thing, but they give different results, why?



Example No. 1:
(define-macro (m lst)
  (eval lst))
(m '(+ 4 5)) ;; -> (+ 4 5)


Example No. 2:
(eval '(+ 4 5)) ;; -> 9