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

#61
newLISP in the real world / Re: Hash-map e contexts
September 10, 2021, 01:57:51 PM
Thank you. I'll do some tests.
#62
newLISP in the real world / Hash-map e contexts
September 09, 2021, 08:16:14 AM
How to filter only the contexts that represent a hash-map?

Example:

(dolist (_el (symbols))

   (if (context? (eval _el))

       (println (eval _el) {} (length (eval _el)))))

; -> Class 2

; -> MAIN 0

; -> Tree 0

; -> demo 0

; -> myHash 0



(dolist (_el (symbols))

   (if (and (context? (eval _el))

       (not (= _el 'MAIN))

       (not (= _el 'Tree))

       (not (= _el 'Class)))

       (println (eval _el) {} (eval-string (string "(" _el ")")))))

; -> demo ()

; -> myHash (("1" 1) ("20" 20) ("57" 57) ("59" 59) ("81" 81))



Is there a way that doesn't use "eval-string" to display / count the values of a context representing a hash-map? "
#63
Italian translation of "Code Patterns in newLISP":

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

cameyo
#64
Solution found.

(define (cmp x y) (if (= (first x) (first y)) (g.t. (last x) (last y)) (l.t. (first x) (first y))))



Fortran operator g.t. and l.t. don't raise Internal Server Error
#65
newLISP in the real world / sort list of points
May 28, 2021, 11:33:23 AM
How to sort a list of points (x y) with x ascending and y descending?

I have tried this, but don't work:

(define (comp x y) (and (>= (last x) (last y)) (<= (first x) (first y))))

I can't post all the code... Internal Server Error.
#66
newLISP in the real world / Re: List of indexes
May 12, 2021, 12:38:12 PM
Thank you guys

Very nice solutions

@rickyboy: "Nota bene" is Italian :-)
#67
newLISP in the real world / List of indexes
May 12, 2021, 05:36:17 AM
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) (1 1 1) (2) (2 0) (2 1))

or

(0 1 (1 0) (1 1) (1 1 0) (1 1 1) 2 (2 0) (2 1))



p.s. can't post formatted code on forum (Internal Server Error)
#68
Thanks again.

I'll test both methods for speed and simplicity.
#69
It works.

But I would also need to pass the function name as a parameter, for example:
(make-adder "add10" 10)
Thanks again for the help
#70
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).
#71
newLISP in the real world / IDE for newLISP
April 08, 2021, 06:33:49 AM
On the web I found this IDE for newLISP:

https://github.com/DexterLagan/newIDE">//https://github.com/DexterLagan/newIDE

by Dexter Santucci



cameyo
#72
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
#73
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: 13

Do you know of another way (instead of using strings) to create a function with another function?
#74
Very nice.

Thank you.
#75
Windows and MacOS. But I can wait without any problems.

Thank you.