Thank you guys
Very nice solutions
@rickyboy: "Nota bene" is Italian :-)
Search found 183 matches
- Wed May 12, 2021 7:38 pm
- Forum: newLISP in the real world
- Topic: List of indexes
- Replies: 5
- Views: 3366
- Wed May 12, 2021 12:36 pm
- Forum: newLISP in the real world
- Topic: List of indexes
- Replies: 5
- Views: 3366
List of indexes
How to create a list of indexes of all the elements of a generic list? Example: Input: (setq lst '(1 (2 (3 4)) (5 6))) (lst 0) 1 (lst 1) (2 (3 4)) (lst 1 0) 2 (lst 1 1) (3 4) (lst 1 1 0) 3 (lst 1 1 1) 4 (lst 2) (5 6) (lst 2 0) 5 (lst 2 1) 6 Output: List of indexes of lst ((0) (1) (1 0) (1 1) (1 1 0)...
- Tue May 04, 2021 5:24 pm
- Forum: newLISP in the real world
- Topic: Create a function with a function
- Replies: 9
- Views: 5233
Re: Create a function with a function
Thanks again.
I'll test both methods for speed and simplicity.
I'll test both methods for speed and simplicity.
- Tue Apr 27, 2021 7:35 pm
- Forum: newLISP in the real world
- Topic: Create a function with a function
- Replies: 9
- Views: 5233
Re: Create a function with a function
It works.
But I would also need to pass the function name as a parameter, for example:
Thanks again for the help
But I would also need to pass the function name as a parameter, for example:
Code: Select all
(make-adder "add10" 10)
- Tue Apr 27, 2021 11:37 am
- Forum: newLISP in the real world
- Topic: Create a function with a function
- Replies: 9
- Views: 5233
Re: Create a function with a function
Thank you, but it doesn't works. The symbol y is not binded.
I am looking for the most suitable/fastest method of generating functions automatically (passing name of function and parameters).
I am looking for the most suitable/fastest method of generating functions automatically (passing name of function and parameters).
- Thu Apr 08, 2021 1:33 pm
- Forum: newLISP in the real world
- Topic: IDE for newLISP
- Replies: 1
- Views: 2178
IDE for newLISP
On the web I found this IDE for newLISP:
https://github.com/DexterLagan/newIDE
by Dexter Santucci
cameyo
https://github.com/DexterLagan/newIDE
by Dexter Santucci
cameyo
- Wed Mar 31, 2021 10:53 am
- Forum: newLISP in the real world
- Topic: error setq symbol with beginn with number
- Replies: 2
- Views: 2530
Re: error setq symbol with beginn with number
Variable symbols should not start with any of the following characters:
# ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9
see "Syntax of symbol variables and numbers" on newLISP manual
# ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9
see "Syntax of symbol variables and numbers" on newLISP manual
- Tue Mar 30, 2021 2:07 pm
- Forum: newLISP in the real world
- Topic: Create a function with a function
- Replies: 9
- Views: 5233
Create a function with a function
Function to create a function with name and parameters: (define (make-add name val) (let (f nil) (setq f (string "(define (" name " x) (+ " val " x))")) (setq name (eval-string f)) name)) Creating a function (make-add "sum-10" 10) out: (lambda (x) (+ 10 x)) Using the created function (sum-10 3) out:...
- Fri Mar 19, 2021 8:16 pm
- Forum: newLISP in the real world
- Topic: Problem to update an array
- Replies: 6
- Views: 4664
Re: Problem to update an array
Very nice.
Thank you.
Thank you.
- Thu Mar 18, 2021 7:31 pm
- Forum: newLISP in the real world
- Topic: Problem to update an array
- Replies: 6
- Views: 4664
Re: Problem to update an array
Windows and MacOS. But I can wait without any problems.
Thank you.
Thank you.
- Wed Mar 17, 2021 6:33 pm
- Forum: newLISP in the real world
- Topic: Problem to update an array
- Replies: 6
- Views: 4664
Re: Problem to update an array
Thanks.
When will be released a compiled version?
Best regards,
cameyo
When will be released a compiled version?
Best regards,
cameyo
- Tue Mar 16, 2021 9:50 pm
- Forum: newLISP in the real world
- Topic: Problem to update an array
- Replies: 6
- Views: 4664
Problem to update an array
I have the following situation: (setq j (array 256 '(-1))) (setq str "abc") (char (str 1)) ;-> 98 (integer? (char (str 1))) ;-> true Now i want to update a value of the array j : Using the number 98 works: (setf (j 98) 2) ;-> 2 Reference with a variable works too: (setq idx (char (str 1))) ;-> 98 (s...
- Tue Mar 16, 2021 5:04 pm
- Forum: So, what can you actually DO with newLISP?
- Topic: Pandigital Magic Square
- Replies: 0
- Views: 3655
Pandigital Magic Square
A pandigital magic square (found with newLISP) having n^2 distinct pandigital integers and having the smallest pandigital magic sum. 1035629784 1035728694 1024638795 1024739685 1025639784 1025738694 1034628795 1034729685 1035729684 1035628794 1024738695 1024639785 1025739684 1025638794 1034728695 10...
- Fri Feb 12, 2021 8:08 am
- Forum: newLISP in the real world
- Topic: Project Euler
- Replies: 0
- Views: 3128
Project Euler
Project Euler https://projecteuler.net/ added newLISP language.
I have solved 102 problems: 1..102.
cameyo
I have solved 102 problems: 1..102.
cameyo
- Thu Oct 29, 2020 12:15 pm
- Forum: So, what can you actually DO with newLISP?
- Topic: Some functions on dates
- Replies: 0
- Views: 4765
Some functions on dates
; julian day = 0 on monday 1 january 4713 B.C. (-4712 1 1) ;; @syntax (gdate-julian gdate) ;; @description Convert gregorian date to julian day number (valid only from 15 ottobre 1582 A.D.) ;; @param <gdate> gregorian date (year month day) ;; @return julian day number (int) ;; @example ;; (gdate-ju...
- Mon Oct 19, 2020 7:25 pm
- Forum: newLISP in the real world
- Topic: pow function problem
- Replies: 2
- Views: 3486
Re: pow function problem
Thanks for the explanation
- Mon Oct 19, 2020 9:11 am
- Forum: newLISP in the real world
- Topic: pow function problem
- Replies: 2
- Views: 3486
pow function problem
I have some problems with the pow function: (pow 3 0.33) ;-> 1.436977652184852 (pow -3 0.33) ;-> 1.#IND In Mathematica (WolframAlpha): 3^0.33 = 1.436977652184852 -3^0.33 = -1.436977652184852 A simple solution: (define (pow-ext x n) (if (< x 0) (sub 0 (pow (sub 0 x) n)) (pow x n))) (pow-ext 3 0.33) ;...
- Sun Oct 04, 2020 7:38 am
- Forum: newLISP in the real world
- Topic: select function for array
- Replies: 0
- Views: 3712
select function for array
"select" function for array: (define (select-array arr lst-idx) (array (length lst-idx) (map (fn(x) (arr x)) lst-idx)) ) Some test: (setq lst '(3 5 6 7 1 9)) (setq vec (array (length lst) lst)) (select-array vec '(0 1)) ;-> (3 5) (select-array vec '(0 1 -1)) ;-> (3 5 9) (select-array vec '(-1 -2 -3 ...
- Wed Sep 23, 2020 12:10 pm
- Forum: newLISP in the real world
- Topic: Array or char bug?
- Replies: 1
- Views: 2612
Re: Array or char bug?
Reading the manual for "char" function...
This solve the problem (on UTF-8 enabled system):
This solve the problem (on UTF-8 enabled system):
Code: Select all
(setf (ar (char (str 0) 0 true)) 555)
;-> 555
- Wed Sep 23, 2020 10:21 am
- Forum: newLISP in the real world
- Topic: Array or char bug?
- Replies: 1
- Views: 2612
Array or char bug?
I have some problem to update an array: ; define an array (setq ar (array 256 '(-1))) ; define a string (setq str "bar") ; define an index (setq idx (char (str 0))) ;-> 98 (number? idx) ;-> true ; update array (setf (ar idx) 555) ;-> 555 (number? (char (str 0))) ;-> true ; update array fail (setf (a...
- Wed Sep 02, 2020 7:34 am
- Forum: newLISP in the real world
- Topic: using ref data
- Replies: 5
- Views: 4957
Re: using ref data
Hi joejoe,
the "ref-all" and "ref" functions have a parameter to get data instead of indexes.
But maybe I misunderstood the question.
cameyo
the "ref-all" and "ref" functions have a parameter to get data instead of indexes.
Code: Select all
(setq lst '(a b c (d a f (a h a)) (k a (m n a) (x))))
(ref-all 'a lst)
;-> ((0) (3 1) (3 3 0) (3 3 2) (4 1) (4 2 2))
(ref-all 'a lst = true)
;-> (a a a a a a)
cameyo
- Thu Aug 13, 2020 11:20 am
- Forum: newLISP in the real world
- Topic: Find single number
- Replies: 4
- Views: 4001
Re: Find single number
My solution using XOR:
Code: Select all
(define (find-number lst) (apply ^ lst))
(find-number '(1 3 1 2 3 4 5 2 4))
;-> 5
- Wed Aug 12, 2020 8:17 am
- Forum: newLISP in the real world
- Topic: Find single number
- Replies: 4
- Views: 4001
Re: Find single number
Hi fdb,
thanks for your solution (hash table is nice).
There is a faster method using a boolean operator...
I'll post my solution in the next days.
cameyo
thanks for your solution (hash table is nice).
There is a faster method using a boolean operator...
I'll post my solution in the next days.
cameyo
- Tue Aug 11, 2020 8:52 am
- Forum: newLISP in the real world
- Topic: Find single number
- Replies: 4
- Views: 4001
Find single number
Given a list of positive integers each number appears twice except one number. Find the single number.
Note: The function has to traverse the list only once (O(n)).
Note: The function has to traverse the list only once (O(n)).
- Thu Jul 23, 2020 3:21 pm
- Forum: Whither newLISP?
- Topic: where is the value which is assigned by setq to a symbol?
- Replies: 4
- Views: 5057
Re: where is the value which is assigned by setq to a symbol?
Maybe you can define 'f in a different way:
or
cameyo
Code: Select all
(set (sym {'f}) 100)
;-> 100
(eval (sym {'f}))
;-> 100
Code: Select all
(set (sym {''f}) 2)
;-> 2
(eval (sym {''f}))
;-> 2