all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: tar@sevak.isi.edu (Thomas A. Russ)
To: help-gnu-emacs@gnu.org
Subject: Re: Random number generation in LISP or using it
Date: 10 Jun 2009 11:21:09 -0700	[thread overview]
Message-ID: <ymiy6s0lzl6.fsf@blackcat.isi.edu> (raw)
In-Reply-To: 0c194ee2-6347-4a46-8932-37d144e9265a@z7g2000vbh.googlegroups.com

bolega <gnuist006@gmail.com> writes:

> The function "random" does not work in emacs. 

How does it not work?
It seems to work for me.

> start line and end line of a marked region and then use that to
> disorder (or re-order) the lines according to a list of random numbers
> generated ?

You could look up shuffling algorithms.


  http://en.wikipedia.org/wiki/Shuffle#Shuffling_algorithms
  http://en.wikipedia.org/wiki/Fisher-Yates_shuffle  


[snip]

> In this case one needs to generate a random number that is an integer
> and lies between the lines start and end of region. It can be done by
> some modulo type operation if available in emacs lisp.

You shouldn't need to do that, since the built-in RANDOM function can do
that for you.  Try ^H f random <CR>

-- 
Thomas A. Russ,  USC/Information Sciences Institute


  parent reply	other threads:[~2009-06-10 18:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10 15:21 Random number generation in LISP or using it bolega
2009-06-10 15:26 ` bolega
2009-06-10 18:04 ` Colin S. Miller
2009-06-10 18:56   ` Lennart Borgman
2009-06-10 18:21 ` Thomas A. Russ [this message]
2009-06-10 18:21 ` Thomas A. Russ
2009-06-10 21:57 ` Xah Lee
2009-06-11  7:34 ` TomSW
2009-07-08 11:54 ` Mario Lang
2009-07-08 12:57   ` Pascal J. Bourguignon

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=ymiy6s0lzl6.fsf@blackcat.isi.edu \
    --to=tar@sevak.isi.edu \
    --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.