all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jeff Clough <jeff@chaosphere.com>
To: help-gnu-emacs@gnu.org
Subject: Re: LISP Questions - random, random elements and memory management
Date: Thu, 19 Nov 2009 06:56:56 -0500 (EST)	[thread overview]
Message-ID: <20091119.065656.255106855.jeff@chaosphere.com> (raw)
In-Reply-To: <he2cim$k0b$1@ger.gmane.org>

From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
Date: Wed, 18 Nov 2009 20:03:51 -0700

> The data *is* in memory.  The function is zippy because nth is fast,
> in
> turn because cdr is fast (and implemented in C).  And perhaps the cons
> cells for the list are allocated in adjacent memory, if it is
> constructed all at once.
> 
> Of course you can put the data (defconst forms) and function (defun)
> in
> the same .el file!

Um, actually I was looking for a way that would allow me to keep the
data *out* of memory until it was needed, then toss it on the floor
when I was done, that way I'm only eating the RAM *some* of the time
instead of all the time.  With my existing scheme, the data is in
memory as soon as the .el file is loaded.

And yes, as your earlier message indicates, the relevant line would
be:

(nth (random (length list)) list)

Overall update:

In absence of reaching enlightenment with the other points, I think
I'm just going to use the above line in my name generator instead of
worrying about defining a new function, put a note in the source about
calling (random t) and not worry about the memory issue for now.

Jeff





  reply	other threads:[~2009-11-19 11:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18 12:54 LISP Questions - random, random elements and memory management Jeff Clough
2009-11-18 13:09 ` Jeff Clough
2009-11-19  2:53   ` Kevin Rodgers
2009-11-19  3:03 ` Kevin Rodgers
2009-11-19 11:56   ` Jeff Clough [this message]
     [not found]   ` <mailman.11040.1258631785.2239.help-gnu-emacs@gnu.org>
2009-11-19 13:44     ` Barry Margolin
2009-11-19 15:16       ` Jeff Clough
2009-11-20  3:52         ` Kevin Rodgers
     [not found]         ` <mailman.11114.1258689162.2239.help-gnu-emacs@gnu.org>
2009-11-20  6:28           ` Barry Margolin
     [not found]       ` <mailman.11056.1258643746.2239.help-gnu-emacs@gnu.org>
2009-11-19 17:40         ` Colin S. Miller
2009-11-19 18:57           ` Jeff Clough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091119.065656.255106855.jeff@chaosphere.com \
    --to=jeff@chaosphere.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.