newLISP Fan Club

Forum => newLISP in the real world => Topic started by: cameyo on March 16, 2026, 02:04:23 PM

Title: Question on $idx
Post by: cameyo on March 16, 2026, 02:04:23 PM
(define (test lst)
  (let (len (length lst))
    (dolist (el lst)
      ; select and index of the list different from the current
      (while (!= (setq idx (rand len)) $idx)))
    (println "index: " idx)))
Why (test '(1 2 3 4 5)) fall (almost always) into an infinite loop?
Why (test '(1)) return always 0? The function should fall into an infinite loop.

I know the answer...