Search found 145 matches

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
by newBert
Thu Jul 21, 2016 9:07 am
Forum: Anything else we might add?
Topic: primitive function empty? could not accept array
Replies: 13
Views: 5454

Re: primitive function empty? could not accept array

By default, we perceive an array as a special case of a list; so we expect it to act like a like in pretty much every way. Yes, but we can't effectively create an empty array : newLISP v.10.7.1 32-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h > (array 0) ERR: wrong dimensions in function ar...
by newBert
Fri Jun 24, 2016 4:24 pm
Forum: newLISP in the real world
Topic: Expand..
Replies: 3
Views: 2251

Re: Expand..

I never managed to get quite good enough at lisp and scheme, but with newlisp I should be vaguely useful for something.. :) I myself tried some Lisp(s) and many Scheme(s), and other scripting languages too, like Python, Perl or Ruby, but I'm definetly not able to manage with them, and at the end I ...
by newBert
Wed Jun 22, 2016 3:32 pm
Forum: newLISP in the real world
Topic: Expand..
Replies: 3
Views: 2251

Re: Expand..

Maybe I'm doing something wrong but I can't get expand to work.. (set 'x 2 'a '(d e)) ; from the examples (expand '(a x(b c x) 'x 'a)) For me this just returns the first list I typed. But I'm just using this on the console, not in any macros.. is this possible?? Many thanks. In the example, we have...
by newBert
Sat Apr 04, 2015 7:43 am
Forum: newLISP in the real world
Topic: Surprising behavior of dolist with break condition.
Replies: 3
Views: 1135

Re: Surprising behavior of dolist with break condition.

Here is another solution :

Code: Select all

(set 'foo '(1 5 10 20 100 105))
(last (ref-all 50 foo > true))   ;-> 20
by newBert
Tue May 20, 2014 3:44 pm
Forum: newLISP in the real world
Topic: Is there a List comprehensions macro?
Replies: 3
Views: 1104

Re: Is there a List comprehensions macro?

Here are some comparisons between Python and NewLisp that I made a long time ago: ;; List Comprehensions in PYTHON ;;>>> vec = [2, 4, 6] ;;>>> [3*x for x in vec] ;;[6, 12, 18] (set 'vec '(2 4 6)) (println (map (lambda (x) (* x 3)) vec)) ;-> (6 12 18) ;;>>> vec = [2, 4, 6] ;;>>> [[x, x**2] for x in v...