Search found 39 matches

by lyl
Fri Jul 24, 2020 7:50 am
Forum: Whither newLISP?
Topic: where is the value which is assigned by setq to a symbol?
Replies: 4
Views: 593

Re: where is the value which is assigned by setq to a symbol?

Many thanks! But where is the value stored in the expression "(setq 'f 100)"
by lyl
Thu Jul 23, 2020 6:49 am
Forum: Whither newLISP?
Topic: where is the value which is assigned by setq to a symbol?
Replies: 4
Views: 593

where is the value which is assigned by setq to a symbol?

I wonder where or how I can get the value which is assign by setq to a symbol like this:

Code: Select all

(setq 'f 100)
'f ;;-> f
''f ;;->'f
How can I get the value 100?
by lyl
Thu Oct 03, 2019 9:59 pm
Forum: newLISP in the real world
Topic: difference result by eval in macro and in S-expr
Replies: 5
Views: 1060

Re: difference result by eval in macro and in S-expr

Thank you, cameyo. I think the argument "lst" of "f" has been evaled during the call of (f a), so why must it be evaled again by "letex" in function body ?
And could you please give more information about the function "typeof"?
by lyl
Thu Oct 03, 2019 8:18 am
Forum: newLISP in the real world
Topic: difference result by eval in macro and in S-expr
Replies: 5
Views: 1060

Re: difference result by eval in macro and in S-expr

Then, in the following example

Code: Select all

(define(f lst)
  (+ lst 1))

(setq a '(+ 2 3)) 
(f a) 
As arguments of function in lisp are evaled first, I think (f a) is the same as (+ (+ 2 3) 1) which should be 6, but what I get is: "ERR: value expected in function + : (+ 2 3)". Why?
by lyl
Thu Sep 26, 2019 6:42 am
Forum: newLISP in the real world
Topic: replace parentheses of a list with quotation marks
Replies: 2
Views: 614

Re: replace parentheses of a list with quotation marks

Thank you, cameyo. In my example, the expression that is to be evaled is the last element in the list which make it possible to use (setf (last lst)...) evaluating the expression. I wonder if there is an universal method to evluating any expression at any position in a list. Here I'd like give anoth...
by lyl
Wed Sep 25, 2019 2:28 am
Forum: newLISP in the real world
Topic: replace parentheses of a list with quotation marks
Replies: 2
Views: 614

replace parentheses of a list with quotation marks

(setq a "time")
(setq b '(set xlabel a))

My question is:
how to design a function to transfer a list("b" in this example) into a string. That is to say, replace the parentheses of b with quotation marks to get "set xlabel "time"".
by lyl
Wed Sep 04, 2019 11:53 am
Forum: newLISP in the real world
Topic: what's wrong with the use of apply append
Replies: 4
Views: 661

Re: what's wrong with the use of apply append

Oh, I understand it! @rickyboy And learn a lot from you. I will use "apply" more carefully.
by lyl
Tue Sep 03, 2019 12:23 pm
Forum: newLISP in the real world
Topic: what's wrong with the use of apply append
Replies: 4
Views: 661

Re: what's wrong with the use of apply append

Thank you so much for this detail explaination. As you say, "so, you end up passing a symbol as the second argument to append". The symbol 'var which is passed to "append" has been binded to "b", why is the evaluator not able to see it? Dose that mean each element of a list which will be passed to a...
by lyl
Tue Sep 03, 2019 6:26 am
Forum: newLISP in the real world
Topic: what's wrong with the use of apply append
Replies: 4
Views: 661

what's wrong with the use of apply append

First example: (setq var "b") (apply append '("a" var)) ;; I believe the result will be "ab", but what I get is error message. Second example: (setq var "b") (append "a" var);; -> "ab" I think the two examples are equivalent, but it seems not. Why? And why the first example is a wrong way to use "ap...
by lyl
Sun Aug 04, 2019 8:39 am
Forum: newLISP in the real world
Topic: How to use "char" for combinated keys
Replies: 0
Views: 1050

How to use "char" for combinated keys

A key value(integer) can be obtained by the built-in function "char".
For example,

Code: Select all

(char "a")          → 97
My question is: How to obtain the value of combinated keys like this:
(myfunc "ctrl a") which means "CTRL + a" . And also "CTRL+Alt+a" , "CTRL+SHIFT+a" are wanted.
Thank you.
by lyl
Thu Aug 01, 2019 3:00 am
Forum: newLISP and the O.S.
Topic: hpwNLAutoItDll released
Replies: 7
Views: 3856

Re: hpwNLAutoItDll released

when :

Code: Select all

(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.
by lyl
Wed Jul 03, 2019 7:41 am
Forum: newLISP in the real world
Topic: How to determine whether a list can be evaluated
Replies: 2
Views: 630

How to determine whether a list can be evaluated

(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: (...
by lyl
Sun Jun 23, 2019 2:06 am
Forum: newLISP in the real world
Topic: How to partially evaluate elements in a hash-table
Replies: 5
Views: 1200

Re: How to partially evaluate elements in a hash-table

Yet, is there a better way to evaluate elements in hash-table when constructing hash-table, as like the comma expression in common lisp?
by lyl
Mon Jun 17, 2019 5:33 am
Forum: newLISP in the real world
Topic: initializer expressions by a predefined list in "let"
Replies: 3
Views: 824

Re: initializer expressions by a predefined list in "let"

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)) ?
by lyl
Sun Jun 16, 2019 12:10 am
Forum: newLISP in the real world
Topic: initializer expressions by a predefined list in "let"
Replies: 3
Views: 824

initializer expressions by a predefined list in "let"

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...
by lyl
Fri Jun 14, 2019 7:42 am
Forum: newLISP in the real world
Topic: How to partially evaluate elements in a hash-table
Replies: 5
Views: 1200

Re: How to partially evaluate elements in a hash-table

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

Code: Select all

'(((char "a") "a: choiceA" (+ 0 101))  ((char "b") "b: choiceB" (+ 0 102)))
to

Code: Select all

'((97 "a: choiceA" (+ 0 101)) (98 "b: choiceB" (+ 0 102)))
by lyl
Fri Jun 14, 2019 6:50 am
Forum: newLISP in the real world
Topic: How to partially evaluate elements in a hash-table
Replies: 5
Views: 1200

How to partially evaluate elements in a hash-table

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...
by lyl
Wed Jun 05, 2019 9:48 am
Forum: newLISP in the real world
Topic: Primitive "case" does not work
Replies: 3
Views: 802

Re: Primitive "case" does not work

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?
by lyl
Wed Jun 05, 2019 8:56 am
Forum: newLISP in the real world
Topic: Primitive "case" does not work
Replies: 3
Views: 802

Primitive "case" does not work

I construct the following function by the primitive "case"

Code: Select all

(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"?
by lyl
Wed Jun 05, 2019 8:42 am
Forum: Anything else we might add?
Topic: case design
Replies: 2
Views: 3203

Re: case design

I meet this problem too, and has been waiting for answer!
by lyl
Mon May 13, 2019 12:28 am
Forum: newLISP and the O.S.
Topic: Compile script to .exe with attached files
Replies: 8
Views: 3293

Re: Compile script to .exe with attached files

Thank you @HPW. My description in the post made my query not clear. I just modified it. Would you please have look at it?
by lyl
Sun May 12, 2019 1:16 pm
Forum: newLISP and the O.S.
Topic: Compile script to .exe with attached files
Replies: 8
Views: 3293

Compile script to .exe with attached files

Source 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"...
by lyl
Sat May 04, 2019 2:35 pm
Forum: newLISP and the O.S.
Topic: How to run a dos command in win7 console by newlisp
Replies: 2
Views: 555

Re: How to run a dos command in win7 console by newlisp

Perfect explanation! I learn a lot. Many thanks!
by lyl
Fri May 03, 2019 11:51 am
Forum: newLISP and the O.S.
Topic: How to run a dos command in win7 console by newlisp
Replies: 2
Views: 555

How to run a dos command in win7 console by newlisp

I want to run the dos command in win7 console by newlisp "exec" to clear secreen like this:

Code: Select all

(exec "cls")
but fails with a feedback ("\f").
Why? And how to deal with this?

PS: Also

Code: Select all

 (exec "color 0b") 
does not work.
by lyl
Sat Apr 27, 2019 11:07 pm
Forum: newLISP in the real world
Topic: difference result by eval in macro and in S-expr
Replies: 5
Views: 1060

difference result by eval in macro and in S-expr

I think the following two examples say the same thing, but they give different results, why?

Example No. 1:

Code: Select all

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

Code: Select all

(eval '(+ 4 5)) ;; -> 9