emacs-devel
[Top][All Lists]
Advanced

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

Re: random doesn't feel very random, random doesn't feel very random, Re


From: Stephen J. Turnbull
Subject: Re: random doesn't feel very random, random doesn't feel very random, Re: random doesn't feel very random
Date: Sat, 25 Aug 2012 03:50:02 +0900

Ivan Kanis writes:
 > "Stephen J. Turnbull" <address@hidden> wrote:

 > > To avoid this behavior, use `(random t)'
 > 
 > I do.

Where?  I don't see it in your `ivan-emms-pick-album' function.  Note,
this will only help across Emacs sessions; within one session the
random function should maintain state across calls to your function,
so it should give different sequences every time as long as you never
exist Emacs.

 > > If it always plays tracks from the same subset of your
 > > collection, but in different orders, you may have made a
 > > programming error.
 > 
 > It sort of does that.

I still don't understand what buggy behavior you are seeing.  Without
a precise description, it's hard to guess what might be wrong in your
code or in `random'.

 > (defun ivan-emms-pick-album (dir length)
 >   "Return a LENGTH albums in a directory DIR."
 >   (let* ((index 0)
 >          (ret (make-vector length nil))
 >          (album (ivan-emms-list-subdir
 >                  (concat ivan-emms-dir dir)))
 >          (album-length (length album)))
 >     (while (< index length)
 >       (aset ret index
 >             (nth (random album-length) album))
 >       (setq index (1+ index)))
 >     ret))

That's the code without WITH-CACHE.  I don't see any problems with it.

Unfortunately the attachment seems to have been stripped so I don't
know what might be going wrong in `ivan-emms-list-subdir' or the code
that calls `ivan-emms-pick-album'.  (Probably nothing, but I can't
review it.)

If you do `M-x (ivan-emms-list-subdir (concat ivan-emms-dir "FOO")) RET'
(with some value for FOO that actually exists and contains albums),
does the answer look right?




reply via email to

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