help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LISP Questions - random, random elements and memory management


From: Jeff Clough
Subject: Re: LISP Questions - random, random elements and memory management
Date: Wed, 18 Nov 2009 08:09:39 -0500 (EST)

From: Jeff Clough <address@hidden>
Date: Wed, 18 Nov 2009 07:54:28 -0500 (EST)

> (defun get-random-element (list)
>   "Returns a random element of LIST."
>   (if (not (and (list) (listp list)))
>       (nth (random (1- (1+ (length list)))) list)
>     (error "Argument to get-random-element not a list or the list is empty")))
> 

Yay for not being awake!  The above should be this:

(defun get-random-element (list)
  "Returns a random element of LIST."
  (if (and list (listp list))
      (nth (random (1- (1+ (length list)))) list)
    (error "Argument to get-random-element not a list or the list is empty")))



Jeff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]