Search found 150 matches

by newBert
Mon Feb 01, 2021 5:31 pm
Forum: newLISP Graphics & Sound
Topic: Running "allegro game library" within NewLisp?
Replies: 1
Views: 1644

Re: Running "allegro game library" within NewLisp?

First, you need to understand how the function import works. And see some examples where it is used, like here for instance (see especially the first part with the 'import' and the 'constant' ). Then after recovering all the functions from Allegro , the rest is a work of patience, a little repetitiv...
by newBert
Wed Sep 02, 2020 10:14 am
Forum: newLISP in the real world
Topic: using ref data
Replies: 5
Views: 1316

Re: using ref data

cameyo wrote:
Wed Sep 02, 2020 7:34 am
the "ref-all" and "ref" functions have a parameter to get data instead of indexes.
Well seen ! I had completely forgotten this option.
Thanks, Cameyo.
by newBert
Mon Aug 31, 2020 1:38 pm
Forum: newLISP in the real world
Topic: using ref data
Replies: 5
Views: 1316

Re: using ref data

Sorry, I don't have time to answer from a concrete example that should first be created. But I think there are some interesting tracks in the wikibook, especially here (see 'find-all' at the end).
by newBert
Mon Aug 31, 2020 1:16 pm
Forum: newLISP in the real world
Topic: how to prevent unwanted eval?
Replies: 1
Views: 640

Re: how to prevent unwanted eval?

One possibility, probably among others: > (define (g (x nil)) x) (lambda ((x nil)) x) > (define-macro (f) (setf (nth '(0 0 1) g) (args 0))) (lambda-macro () (setf (nth '(0 0 1) g) (args 0))) > (f 1) 1 > (g) 1 > (f '(+ 1 2)) '(+ 1 2) > (g) (+ 1 2) P.S. : I preferred (args 0) instead of 'data' for mac...
by newBert
Fri Aug 28, 2020 10:21 am
Forum: newLISP in the real world
Topic: Setup functions by setq
Replies: 1
Views: 628

Re: Setup functions by setq

lyl wrote:
Fri Aug 28, 2020 5:54 am

Code: Select all

(setq a '(a1 a2))
(dolist (x a)
  (let (z $idx)
    (setq x (lambda(y) z))
    ))
What's wrong with my code, and how to solve it?
Maybe with :

Code: Select all

(dolist (x a)
  (let (z $idx)
    (set (sym x) (expand (lambda (y) z) 'z))))
by newBert
Fri Jul 03, 2020 1:22 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 1570

Re: Sum of integers in a string

cameyo wrote:
Fri Jul 03, 2020 10:26 am
thank you. I learned new things.
You're welcome! I learned new things too... :)
by newBert
Thu Jul 02, 2020 12:02 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 1570

Re: Sum of integers in a string

In this case we could also do:

Code: Select all

> (apply + (map (fn (x) (int (if (starts-with x "0") (rest x) x))) (find-all {[0-9]+} "o123p010iru5")))
138
by newBert
Mon May 25, 2020 11:01 am
Forum: newLISP in the real world
Topic: From "The Little Schemer" to newLISP
Replies: 2
Views: 1031

Re: From "The Little Schemer" to newLISP

I think the definition of ‘rember-f’ is wrong. A correct writing of this lambda would be : (define rember-f (lambda (test? a l) (cond ((null? l) '()) ((test? (first l) a) (rest l)) (true (cons (first l) (rember-f test? a (rest l))))))) > (rember-f = 'tuna '(shrimp salad and tuna salad)) (shrimp sala...
by newBert
Mon May 25, 2020 9:04 am
Forum: newLISP in the real world
Topic: Parallel assignment
Replies: 3
Views: 1060

Re: Parallel assignment

Yes, map is a very useful function which works well in parallel.
It is handy too to take the place of ‘list comprehensions’...
by newBert
Mon May 25, 2020 8:43 am
Forum: newLISP in the real world
Topic: Parallel assignment
Replies: 3
Views: 1060

Re: Parallel assignment

Just another way to do it (with what comes to hand):

Code: Select all

> (setq x 2 y 3)
3
> (map set '(x y) (list (+ 1 y) (+ 1 x)))
(4 3)

> (setq x 1 y 2 z 3)
3
> (map set '(x y z) (list (+ x y z) (- z y x) (- x y z)))
(6 0 -4)
 
:)
by newBert
Sun May 24, 2020 5:57 pm
Forum: newLISP in the real world
Topic: How to determine whether a list can be evaluated
Replies: 2
Views: 1316

Re: How to determine whether a list can be evaluated

My quesstion is: Is there an universal method to determine whether a list can be evaluated or not? Oops ! Why didn't I think of catch ? > (setq a '(1 2 3)) (1 2 3) > (catch (eval a) 'result) nil ; `a` can't be evaluated (see error below in `result`) > result "ERR: illegal parameter type in function...
by newBert
Sun May 24, 2020 10:19 am
Forum: newLISP Graphics & Sound
Topic: Combo-box
Replies: 1
Views: 2645

Re: Combo-box

Sorry for the late answer, but the forum was inaccessible for a moment.
I think the solution is in “widgets-demo.lsp”.
Maybe you should use ‘base64-dec’ to decode the value of combo-box.
by newBert
Sat Jul 13, 2019 9:08 am
Forum: newLISP in the real world
Topic: How to determine whether a list can be evaluated
Replies: 2
Views: 1316

Re: How to determine whether a list can be evaluated

(setq a '(1 2 3)) ;; This list can not be evaled It's normal, because ‘1’ is neither a primitive nor a lambda (setq b '(1 a)) ;; This list can be evaled, (eval b) --> (2 3) Also normal, because (1 a) is equivalent to (rest a) <- implicit indexing (setq c '(+ 1 2)) ;; This list can be evaled, (eval ...
by newBert
Thu Mar 07, 2019 5:33 pm
Forum: newLISP in the real world
Topic: let and letn
Replies: 4
Views: 1802

Re: let and letn [resolved]

Indeed, I've just tried again now, in a new NewLISP session, and I get the expected result: (1 2 3 (4 5 6 7) (nil nil nil nil)) . I'm reassured :). Thank you , RalphRonnquist, Cameyo and Rickyboy for your replies and advice. I don't know what could have happened... I probably forgot NewLISP has no l...
by newBert
Mon Mar 04, 2019 1:30 pm
Forum: newLISP in the real world
Topic: let and letn
Replies: 4
Views: 1802

let and letn

I don't understand why letn isn't required here, or why let doesn't cause an error:

Code: Select all

(let (a 1 b 2 c 3 d '(4 5 6 7) e (flat (list a b c d)))
  (println (list a b c d e)))
;−> (1 2 3 (4 5 6 7) (1 2 3 4 5 6 7))
by newBert
Mon Mar 04, 2019 12:18 pm
Forum: newLISP in the real world
Topic: list of functions question
Replies: 3
Views: 1625

Re: list of functions question

(With some delay...)
I think we could also write: (set 'funclist (list myfunc myfunc myfunc myfunc myfunc)), so we don't need ‘eval’ in (set 'afunc (funclist 2))
by newBert
Sat Dec 22, 2018 12:36 pm
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 2548

Re: anti-select elements of a list

Here is a solution (probably not the only one, nor the best) : newLISP v.10.7.5 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h > (select '(0 1 2 3 4) (difference (index true? '(0 1 2 3 4)) '(1 2))) (0 3 4) > ;; maybe clearer: > (let (lst '(0 1 2 3 4)) (select lst (difference (index true? ...
by newBert
Fri Dec 21, 2018 10:37 am
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 2548

Re: anti-select elements of a list

Here is a solution (probably not the only one, nor the best) : newLISP v.10.7.5 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h > (select '(0 1 2 3 4) (difference (index true? '(0 1 2 3 4)) '(1 2))) (0 3 4) > ;; maybe clearer: > (let (lst '(0 1 2 3 4)) (select lst (difference (index true? l...
by newBert
Sat Oct 27, 2018 4:44 pm
Forum: newLISP in the real world
Topic: FUNCALL and GETDEF
Replies: 3
Views: 1798

Re: FUNCALL and GETDEF

Hi newbert, I have found these functions in an old article on Lisp (to define a function it use DE, maybe Portable Standard Lisp). GETDEF gets the definition of a function. Thanks for infos. A Function in newLISP is not a "closure", so we can examine its content typing its name without parentheses ...
by newBert
Fri Oct 26, 2018 4:33 pm
Forum: newLISP in the real world
Topic: FUNCALL and GETDEF
Replies: 3
Views: 1798

Re: FUNCALL and GETDEF

I think there is no need to 'funcall' in newLisp, because variable name space and function name space are not separated as in Common Lisp, and maybe for other reasons, but I may be mistaken...

As for 'getdef', I can't give an answer because i don't know what is the use of this function in CL. Sorry !
by newBert
Sun Aug 12, 2018 11:34 am
Forum: newLISP in the real world
Topic: Any new releases, planned future
Replies: 5
Views: 2749

Re: Any new releases, planned future

Hi All, I'm curious if any new releases are on the horizon, and if there are future plans for newlisp in general. Love the language and programming in newlisp, I only wish it were a more general purpose platform / language, but I know it's not in the cards. To my knowledge, I don't know any lisp-li...
by newBert
Sun Feb 25, 2018 5:51 pm
Forum: newLISP in the real world
Topic: Error in newLISP-GS
Replies: 2
Views: 2013

Re: Error in newLISP-GS

Me too ! When you described the phenomenon two days ago, I could reproduce it three times at least, but today not at all, strangely! PS : the same error reappears when I come back once more on the tab 'untitled.lsp' after having done the opposite operation (cut in 'untitled.lsp' and paste again in t...
by newBert
Thu Jan 19, 2017 10:20 am
Forum: newLISP in the real world
Topic: Why this forum's link not exists in newlisp's home page?
Replies: 2
Views: 1899

Re: Why this forum's link not exists in newlisp's home page?

iNPRwANG wrote:Why this forum's link not exists in newlisp's home page?
It exists in the About-page in "20.Where do I file bug reports?" and in the Links-page in "Code collections and blogs" ... :)
by newBert
Tue Nov 29, 2016 10:01 am
Forum: newLISP Graphics & Sound
Topic: Tk (or other) GUI in newLisp (single executable)
Replies: 11
Views: 8804

Re: Tk (or other) GUI in newLisp (single executable)

Just to inform: on my linux, I usually use this little module (a lightly modified 'runtk') : ;;;; ;;;; Module 'tk' ;;;; newLISP + tk ('runtk' légèrement modifié - avril 2015) ;;;; ;;;; d'après runtk v 1.4 updated for 10.1 LM Nov 27th, 2009 ;;;; original version by Fanda: ;;;; http://www.intricatevis...
by newBert
Mon Oct 03, 2016 8:45 am
Forum: newLISP Graphics & Sound
Topic: Setting a checkbox programatically?
Replies: 1
Views: 4046

Re: Setting a checkbox programatically?

I'm not a regular user of newLISP-GS(*) but I think you might try gs:set-selected...

(*) I feel more comfortable with newLISP-Tk