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

Messages - cameyo

#46
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
#47
Hi Ralph, i have two functions to solve puzzle like this: one uses brute-force and the other uses "amb" :-))

https://github.com/cameyo42/newLISP-Note/blob/master/15-note-libere-7.lsp#L9296">//https://github.com/cameyo42/newLISP-Note/blob/master/15-note-libere-7.lsp#L9296
#48
((("e" 9) ("f" 7) ("i" 6) ("l" 2) ("n" 1) ("p" 0) ("s" 4) ("u" 5) ("w" 8))
 (("e" 8) ("f" 2) ("i" 3) ("l" 7) ("n" 1) ("p" 0) ("s" 6) ("u" 5) ("w" 4))
 (("e" 9) ("f" 2) ("i" 8) ("l" 7) ("n" 1) ("p" 0) ("s" 4) ("u" 5) ("w" 6)))
#49
Solve this (each letter represent a different digit):
  LISP *
    FUN =
---------
NEWLISP

There are three solution.

p.s. obviously you have to use newlisp :-)
#50
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.
#51
Anything else we might add? / Re: forum problems?
February 18, 2022, 11:35:10 AM
Hope someone will fix this problem...
#52
Thanks pda
#53
newLISP in the real world / Re: Hash-map e contexts
January 14, 2022, 06:44:02 AM
This works for me:
(define (hash? hash)
  (and (context? (evals hash))
       (not (list? (evals (sym (term hash) hash nil))))))

With "eval" instead of "evals" (to avoid "Internal server error")
#54
newLISP newS / Re: Error in 10.7.6
December 29, 2021, 08:24:43 AM
> (push x x)
(?)
> (x 0 0)
ERR: list reference changed
x

Boom
#55
(println "Happy New Year " (- 1 (- 2 (- 3 (* 4 (- 5 (+ 6 (* 7 8 9))))))))
#56
newLISP newS / Re: Error in 10.7.6
December 29, 2021, 04:40:51 AM
newlisp 10.7.5. windows 10

(push x x)

(?)

(push x x)

((?) ?)

(first x)

(?)
#57
newLISP newS / Re: Happy Birthday newLisp
December 16, 2021, 09:50:21 AM
Congratulations!
#58
A library (181 functions) for recreational mathematics: yo.zip

https://github.com/cameyo42/newLISP-Note">//https://github.com/cameyo42/newLISP-Note
#59
newLISP newS / Re: newLISP_in_21_minutes.html, part 2
November 05, 2021, 07:42:35 AM
Hi Yussi,

the server forum has some problems to render code and some other chars.

I hope someone fix this.

Thanks for your work
#60
newLISP in the real world / Re: Hash-map e contexts
September 18, 2021, 03:14:11 AM
More difficulties:

a context with functor and functions can be a hash-map too.