Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - cameyo

#1
Whither newLISP? / Strange behavior
April 19, 2024, 12:28:25 PM

(define (test a) (extend '() (sequence 1 a)))
(test 4)
;-> (1 2 3 4)
(test 4)
;-> (1 2 3 4 1 2 3 4)
(test 4)
;-> (1 2 3 4 1 2 3 4 1 2 3 4)
test
;-> (lambda (a) (extend '(1 2 3 4 1 2 3 4) (sequence 1 a)))
#2
newLISP in the real world / rotate bug?
December 19, 2023, 05:23:26 AM
Maybe a bug of "rotate" when negative rotations and absolute rotations multiple of length of list.

(rotate '("1" "A" "B" "2") 8)
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") -8)
;-> ("1") ;ERROR
(rotate '("1" "A" "B" "2") 12)
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") -12)
;-> ("1") ;ERROR

Workaround:
(rotate lst (- (% r (length lst))))
(rotate '("1" "A" "B" "2") (- (% 12 4)))
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") (- (% 8 4)))
;-> ("1" "A" "B" "2")

#3
Given a string, how to reverse lowercase to uppercase and vice versa with a "regex"?
#4
newLISP and the O.S. / Windows clipboard
October 09, 2023, 06:00:10 AM
Do you known a way to manage windows clipboard (cut, copy, paste)?
I have tried to use clipboard.dll with no luck.
Thanks.

cameyo
#5
newLISP in the real world / newLISP Note
June 03, 2023, 09:07:51 AM
newLISP Note
more than 2000 newLISP topics (Project euler, Rosetta code, Programmers Interview, ...)
cameyo
p.s. it's written in Italian (but not the code ;)) and I'm just an amateur :)
#6
Whither newLISP? / Searching on array
February 01, 2023, 07:06:15 AM
How to search a value in array ?

Use array-list and then find, ref, etc ?
#7
So, what can you actually DO with newLISP? / chatGPT
January 21, 2023, 12:24:36 AM
chatGPT is able to write code in newlisp!!!

Some errors, but it is fun.

Try: "write code in newlisp to solve quadratic equation"
#8
I'm looking for old versions of newLISP manual (historic reasons).

Any version is appreciated.

Thank you

cameyo
#9
Anything else we might add? / Auguri
December 25, 2022, 09:51:22 AM
Best wishes to all
(println "Happy " (add 1 (div 2 (div 3 (add 4 5 (mul 6 7 8 9))))))
#10
So, what can you actually DO with newLISP? / newlisp note
November 23, 2022, 08:44:33 AM
Over one thousand of problems solved with newlisp.

https://github.com/cameyo42/newLISP-Note">//https://github.com/cameyo42/newLISP-Note

So much fun with newlisp.

Thanks Lutz
#11
newLISP newS / Lisp book
July 27, 2022, 05:21:11 AM
Lisp Book (Croatian language) by Kazimir Majorinc at:

http://monoskop.org/images/c/cb/Majorinc_Kazimir_Mocan_koliko_je_god_moguce.pdf">//http://monoskop.org/images/c/cb/Majorinc_Kazimir_Mocan_koliko_je_god_moguce.pdf



Traslation in english "As Powerful As Possible" at:

https://github.com/amno1/as-powerful-as-possible">//https://github.com/amno1/as-powerful-as-possible
#12
newLISP in the real world / Function as list
July 04, 2022, 06:53:35 AM
https://gist.github.com/cameyo42/13fb05eb49769e5f64913b624507c14e">//https://gist.github.com/cameyo42/13fb05eb49769e5f64913b624507c14e

Can't post code on forum :-(
#13
newLISP in the real world / string function
June 13, 2022, 10:43:11 PM
Why this?
(setq a 10)
(setq b 20)
(string "'"a" '"b"")
-> "'10 '20"
#14
https://github.com/cameyo42/newLISP-Note/blob/master/17-note-libere-9.lsp#L456">//https://github.com/cameyo42/newLISP-Note/blob/master/17-note-libere-9.lsp#L456

(useful for testing purpose)
#15
newLISP in the real world / setq '
June 01, 2022, 09:32:46 AM
(setq 'a 3)
output: 3
a
output: nil


Which symbol is binded with 3?

How to retrieve it?



p.s. it's only a curiosity
#16
Decrypt this message:

"WQGI XH BJ HKOUHVO MWCAAP EEQG JDRPJMVH XQZ KSWSJJ STHSKGL XXLU TOXF."
#17
Anything else we might add? / Forum is broken
April 22, 2022, 03:36:21 AM
I can't post code on this forum.

I hope someone can solve the problem.

Thanks
#18
Example:
(new Tree 'hh)
(for (i 1 5)
  (setq key (string i))
  (for (k i 1 -1)
    (hh key (if DOLLAR-it (extend (list k) DOLLAR-it)  (list k)))
  )
)
(hh)

output: (("1" (1)) ("2" (1 2)) ("3" (1 2 3)) ("4" (1 2 3 4)) ("5" (1 2 3 4 5)))

Note: DOLLAR-it is $it
#19
Solve this (each letter represent a different digit):
  LISP *
    FUN =
---------
NEWLISP

There are three solution.

p.s. obviously you have to use newlisp :-)
#20
With ImageMagick is possible to create an image from within newLISP.

ImageMagick : https://imagemagick.org/">https://imagemagick.org/

The following command of ImageMagick creates an image "image.png" from a text file "pixels.txt":



convert pixels.txt image.png



The following command of ImageMagick creates an image "image.png" (with a white background) from a text file "pixels.txt":



convert pixels.txt -background white -flatten image.png



The structure of text file is this:



# ImageMagick pixel enumeration: 4,4,255,rgba

0,0: (187,102,127,128)

0,1: ( 51,153,127,10)

0,2: (204,102,127,255)

0,3: ( 68,153,127,128)

1,1: ( 51,153,127,200)

1,2: (204,102,127,255)

1,3: ( 68,153,127,255)

2,0: (187,102,127,150)

2,1: ( 51,153,127,128)

2,2: (204,102,127,45)

3,0: (187,102,127,255)

3,1: ( 51,153,127,255)

3,2: (204,102,127,150)



The first line (header) of the image is packed with the basic information about the image.

The information consists of:

File Magic: The image header defines this file as a the special IM text image format (ImageMagick pixel enumeration:)

Image Size: The next two numbers (4,4) define the size of the image contained in this file. Multiplying these numbers together will also tell you how many lines should follow the header to fully define the image.

MaxValue: The last number in the header defines the 'maximum value' of the image data that is possible. In the above examples this was '255' which is a result of using a 8 bit depth.

Colorspace: The last item in the header defines the colorspace of the data that follows. If the image contained any transparency, a final letter 'a' (for alpha) is also appended to the colorspace name, and an extra column of numbers added between parenthesis.



You do not need to define all the pixels in the image.

In fact you do not even need to have the pixels in the correct order.

ImageMagick will just read each pixel defining line in turn, and 'draw' it onto a blank image canvas.

More information at:

https://legacy.imagemagick.org/Usage/files">https://legacy.imagemagick.org/Usage/files



To create an image from within newLISP:



(exxec "convert pixels.txt image.png")



I have used this to create images of clifford attractor.