From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel 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 Message-ID: <87ehmwuntx.fsf@uwakimon.sk.tsukuba.ac.jp> References: <876288yh72.fsf@kanis.fr> <87ipc8vkj6.fsf@uwakimon.sk.tsukuba.ac.jp> <87mx1kdd2i.fsf@thinkpad.tsdh.de> <87d32g9pmq.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: ger.gmane.org 1345834230 13200 80.91.229.3 (24 Aug 2012 18:50:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Aug 2012 18:50:30 +0000 (UTC) Cc: emacs devel To: Ivan Kanis Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 24 20:50:29 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T4yxe-0001HE-As for ged-emacs-devel@m.gmane.org; Fri, 24 Aug 2012 20:50:26 +0200 Original-Received: from localhost ([::1]:58358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4yxc-0000H3-07 for ged-emacs-devel@m.gmane.org; Fri, 24 Aug 2012 14:50:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4yxT-0000GB-Uu for emacs-devel@gnu.org; Fri, 24 Aug 2012 14:50:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4yxP-0003Sm-AG for emacs-devel@gnu.org; Fri, 24 Aug 2012 14:50:14 -0400 Original-Received: from mgmt2.sk.tsukuba.ac.jp ([130.158.97.224]:39906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4yxP-0003FT-0X for emacs-devel@gnu.org; Fri, 24 Aug 2012 14:50:11 -0400 Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mgmt2.sk.tsukuba.ac.jp (Postfix) with ESMTP id 813E69708B0; Sat, 25 Aug 2012 03:50:02 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id 486C812081B; Sat, 25 Aug 2012 03:50:02 +0900 (JST) In-Reply-To: <87d32g9pmq.fsf@googlemail.com> X-Mailer: VM 8.0.12-devo-585 under 21.5 (beta32) "habanero" b0d40183ac79 XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.158.97.224 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152817 Archived-At: Ivan Kanis writes: > "Stephen J. Turnbull" 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?