Recent posts

#31
newLISP in the real world / Re: A simple(?) problem
Last post by rrq - June 26, 2024, 02:08:55 PM
Yeah. Way faster than mine :)

chhers
#32
newLISP in the real world / Re: A simple(?) problem
Last post by cameyo - June 26, 2024, 11:36:06 AM
Thanks Ralph.
This is my solution:
(define (create-valid-numbers current)
  (if (<= current max-val)
      (begin
        (if (and (>= current min-val) (<= current max-val))
            (push current valid-numbers))
        ; creates numbers recursively
        (dolist (d digits)
          (create-valid-numbers (+ (* current 10) d))))))

(define (random-integer min-val max-val digits)
  (let (valid-numbers'())
    (dolist (d digits) (create-valid-numbers d))
    (valid-numbers (rand (length valid-numbers)))))

(random-integer 1 300 '(1 2 3))
;-> 21

(time (println (random-integer 1 90000000 '(1 2 3 4 5 6 7))))
;-> 44377532
;-> 6875.421
#33
newLISP in the real world / Re: A simple(?) problem
Last post by rrq - June 25, 2024, 05:37:41 AM
This one is straight-forward but probably a bit slow
(define    (randint RANGE DIGITS)
  (letn ((digits (fn (X) (map int (unique (explode (string X))))))
         (wrong (fn (X) (difference (digits X) DIGITS)))
         (S (clean wrong (apply sequence RANGE))))
    (S (rand (length S)))))

EDIT: simplify by using "apply"

EDIT 2: recusive digitization might be faster (?)
EDIT 3: changed back to use stringifying; looks nicer :)
#34
newLISP in the real world / A simple(?) problem
Last post by cameyo - June 17, 2024, 10:34:36 AM
Write a function that generates a random integer within a closed interval and with predefined digits.

For example:
Range: (1 200)
Digits: 1 2 3
Possible numbers: 1 2 3 11 21 31 12 22 32 13 23 33
 111 211 311 121 221 321 131 231 331 112 212 312 122 222
 322 132 232 332 113 213 313 123 223 323 133 233 333
Numbers in the range: 1 2 3 11 21 31 12 22 32 13 23 33
 111 112 113 121 122 123 131 132 133
Random Number: Any of the numbers in the range
#35
Whither newLISP? / Re: Strange behavior
Last post by fdb - April 25, 2024, 01:42:02 PM
extend is destructive, so in place extending the list. if you do not want this use append
#36
Whither newLISP? / Strange behavior
Last post by cameyo - 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)))
#37
Quote from: pber on April 15, 2024, 07:13:47 AMMany thanks, itistoday, for you effort on newLISP.

🙇�♂️

Quote from: pber on April 15, 2024, 07:13:47 AMI`m studing his codebase and I`m starting to feel a profound feeling of respect and regard for him and his code, which is great (IMHO).

I hope to publish something about my project (Ike) in order to find help from you Lisp coders.

😎👍
#38
newLISP in the real world / fuzzy logic
Last post by vashushpanov - April 17, 2024, 02:06:20 AM
Luis Argüelles Méndez

A Practical Introduction
to Fuzzy Logic using LISP

Very good book!
Describes fuzzy logic using NewLisp.
#39
So, what can you actually DO with newLISP? / (send 'Hello 'to World)
Last post by pber - April 15, 2024, 07:13:47 AM
Many thanks, @itistoday, for you effort on newLISP.

I hope Lutz is in great form, today, just... elsewhere. I`m studing his codebase and I`m starting to feel a profound feeling of respect and regard for him and his code, which is great (IMHO).

I hope to publish something about my project (Ike) in order to find help from you Lisp coders.
I'm a f* C/C++ coder. I know lisp from decades (because I tried to use Xemacs/Emacs for at least 15 years), but I`m still not able to think, in Lisp.
I understand I think just in C, C++ or Smalltalk, but not in Lisp...
#40
Anything else we might add? / Re: v10.76 ffi interface does ...
Last post by sjain59 - March 13, 2024, 11:41:57 PM
I apoligize humbly. I have reproduced your result. I must have done something wrong to get the segfault. Many thanks.