Search found 44 matches

by lyl
Wed Nov 25, 2020 7:58 am
Forum: newLISP and the O.S.
Topic: HOWTO - Hiding the console on Windows
Replies: 1
Views: 4196

Re: HOWTO - Hiding the console on Windows

A good solution! Then, what or where is use of "SW_SHOW" in your code?
by lyl
Sun Aug 30, 2020 12:35 am
Forum: newLISP in the real world
Topic: how to prevent unwanted eval?
Replies: 1
Views: 2592

how to prevent unwanted eval?

I use a function "f" to store data by calling another function "g" like this: (define (g (x y)) x) (define (f data) (setf (nth '(0 0 1) g) data) ) ;;test: (f 1) (g) ;; -> 1 Right. This is what I want. (g) ;; -> 1 Right. This is what I want. (f '(+ 1 2)) (g) ;; -> 3 This is not what I want. I can't u...
by lyl
Fri Aug 28, 2020 5:54 am
Forum: newLISP in the real world
Topic: Setup functions by setq
Replies: 1
Views: 2510

Setup functions by setq

I'd like to make a series of functions whose names come from a list, as shown by the following codes: (setq a '(a1 a2)) (dolist (x a) (let (z $idx) (setq x (lambda(y) z)) )) what I want is to get two functions a1: (lambda (y) 0) a2: (lambda (y) 1) But I fail. What's wrong with my code, and how to so...
by lyl
Fri Aug 28, 2020 5:31 am
Forum: Whither newLISP?
Topic: "place" in the function "inc"
Replies: 5
Views: 7234

Re: "place" in the function "inc"

Many thanks.
Still, how is the lambda list updated in my example? Or, which element of the lambda list is changed by inc?
by lyl
Wed Aug 26, 2020 9:56 am
Forum: Whither newLISP?
Topic: "place" in the function "inc"
Replies: 5
Views: 7234

"place" in the function "inc"

The meaning of "place" in the syntax: (inc place [num]) is: either a symbol or a place in a list structure holding a number, or a number returned by an expression.(from the newlisp manuel) I still don't quite understand the real meaning of "place", as in the following code coming from 《Code Patterns...
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: 5034

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: 5034

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: 4889

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: 4889

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: 3200

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: 3200

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: 4160

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: 4160

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: 4160

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: 4703

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: 8703

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: 3432

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: 4788

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: 3578

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: 3578

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: 4788

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: 4788

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: 3453

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: 3453

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: 6416

Re: case design

I meet this problem too, and has been waiting for answer!