Search found 128 matches

by cameyo
Thu Apr 08, 2021 1:33 pm
Forum: newLISP in the real world
Topic: IDE for newLISP
Replies: 1
Views: 83

IDE for newLISP

On the web I found this IDE for newLISP:
https://github.com/DexterLagan/newIDE
by Dexter Santucci

cameyo
by 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: 115

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
by cameyo
Tue Mar 30, 2021 2:07 pm
Forum: newLISP in the real world
Topic: Create a function with a function
Replies: 0
Views: 90

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:...
by cameyo
Fri Mar 19, 2021 8:16 pm
Forum: newLISP in the real world
Topic: Problem to update an array
Replies: 6
Views: 346

Re: Problem to update an array

Very nice.
Thank you.
by cameyo
Thu Mar 18, 2021 7:31 pm
Forum: newLISP in the real world
Topic: Problem to update an array
Replies: 6
Views: 346

Re: Problem to update an array

Windows and MacOS. But I can wait without any problems.
Thank you.
by cameyo
Wed Mar 17, 2021 6:33 pm
Forum: newLISP in the real world
Topic: Problem to update an array
Replies: 6
Views: 346

Re: Problem to update an array

Thanks.
When will be released a compiled version?
Best regards,
cameyo
by cameyo
Tue Mar 16, 2021 9:50 pm
Forum: newLISP in the real world
Topic: Problem to update an array
Replies: 6
Views: 346

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...
by cameyo
Tue Mar 16, 2021 5:04 pm
Forum: So, what can you actually DO with newLISP?
Topic: Pandigital Magic Square
Replies: 0
Views: 253

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...
by cameyo
Fri Feb 12, 2021 8:08 am
Forum: newLISP in the real world
Topic: Project Euler
Replies: 0
Views: 762

Project Euler

Project Euler https://projecteuler.net/ added newLISP language.
I have solved 102 problems: 1..102.

cameyo
by 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: 2187

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...
by cameyo
Mon Oct 19, 2020 7:25 pm
Forum: newLISP in the real world
Topic: pow function problem
Replies: 2
Views: 919

Re: pow function problem

Thanks for the explanation
by cameyo
Mon Oct 19, 2020 9:11 am
Forum: newLISP in the real world
Topic: pow function problem
Replies: 2
Views: 919

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) ;...
by cameyo
Sun Oct 04, 2020 7:38 am
Forum: newLISP in the real world
Topic: select function for array
Replies: 0
Views: 1353

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 ...
by cameyo
Wed Sep 23, 2020 12:10 pm
Forum: newLISP in the real world
Topic: Array or char bug?
Replies: 1
Views: 728

Re: Array or char bug?

Reading the manual for "char" function...
This solve the problem (on UTF-8 enabled system):

Code: Select all

(setf (ar (char (str 0) 0 true)) 555)
;-> 555
by cameyo
Wed Sep 23, 2020 10:21 am
Forum: newLISP in the real world
Topic: Array or char bug?
Replies: 1
Views: 728

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...
by cameyo
Wed Sep 02, 2020 7:34 am
Forum: newLISP in the real world
Topic: using ref data
Replies: 5
Views: 1333

Re: using ref data

Hi joejoe,
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)
But maybe I misunderstood the question.
cameyo
by cameyo
Thu Aug 13, 2020 11:20 am
Forum: newLISP in the real world
Topic: Find single number
Replies: 4
Views: 1194

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
by cameyo
Wed Aug 12, 2020 8:17 am
Forum: newLISP in the real world
Topic: Find single number
Replies: 4
Views: 1194

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
by cameyo
Tue Aug 11, 2020 8:52 am
Forum: newLISP in the real world
Topic: Find single number
Replies: 4
Views: 1194

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)).
by cameyo
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: 1753

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

Maybe you can define 'f in a different way:

Code: Select all

(set (sym {'f}) 100)
;-> 100
(eval (sym {'f}))
;-> 100
or

Code: Select all

(set (sym {''f}) 2)
;-> 2
(eval (sym {''f}))
;-> 2
cameyo
by cameyo
Thu Jul 09, 2020 4:12 pm
Forum: newLISP in the real world
Topic: List of user symbols
Replies: 0
Views: 2208

List of user symbols

A function to list the user symbols: (define (user-symbols) (local (_func _other) (setq _func '()) (setq _other '()) (dolist (_el (symbols)) (if (and (lambda? (eval _el)) (not (= _el 'user-symbols))) (push _el _func -1)) (if (and (not (lambda? (eval _el))) (not (primitive? (eval _el))) (not (protect...
by cameyo
Fri Jul 03, 2020 10:26 am
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 1595

Re: Sum of integers in a string

thank you. I learned new things.
by cameyo
Wed Jul 01, 2020 12:50 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 1595

Re: Sum of integers in a string

Hi fdb, thanks for your functions. Only a problem: numbers with leading 0 will convert in octal base. Es. (parse-str "o123p010iru5") -> 136 (the correct value is 138) My function: (define (sum-str str) (local (numeri expr) (setq numeri '()) (setq expr {[0-9]+}) (replace expr str (push $0 numeri -1) ...
by cameyo
Tue Jun 30, 2020 3:37 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 1595

Sum of integers in a string

A string consist of digits and non-digit characters. The digits contains a series of positive integers. For instance, the string “abc22zit62de0f” contains the integers 22, 62 and 0.
Write a function to calculate the sum of the integers inside a string (es. 22 + 62 + 0 = 84)
by cameyo
Wed Jun 17, 2020 10:01 am
Forum: newLISP in the real world
Topic: Sorting nil and true
Replies: 1
Views: 865

Re: Sorting nil and true

I have found this method:

Code: Select all

(setq lst '(true nil true b a))
(map sym (sort (map string lst)))
;-> (a b nil true true)
cameyo