unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@elta.co.il>
Subject: Re: How to create random characters?
Date: 14 Dec 2003 13:10:48 +0200	[thread overview]
Message-ID: <u7k0z8xjb.fsf@elta.co.il> (raw)
In-Reply-To: <wkr7z7oh2f.fsf@studiojungle.net> (message from Brad Collins on Sun, 14 Dec 2003 16:59:52 +0700)

> From: Brad Collins <brad@studiojungle.net>
> Date: Sun, 14 Dec 2003 16:59:52 +0700
> 
> I want to generate a random id which is in the format of XXX-0000
> where 'XXX' is made up of ascii characters a-z and 0000 is a random
> number 0000-9999.
> 
> I found random -- so that (random 10000) produces the number very
> nicely but I can't find anything that will produce three random
> characters in the same way.

Characters are just small integers, so evaluating the following
expression for each of the 3 characters:

   (+ ?a (random (- ?z ?a)))

will give you 3 random numbers between the ASCII code of `a' and that
of `z'.

Does this solve your problem?

  reply	other threads:[~2003-12-14 11:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-14  9:59 How to create random characters? Brad Collins
2003-12-14 11:10 ` Eli Zaretskii [this message]
     [not found] ` <mailman.53.1071403922.868.help-gnu-emacs@gnu.org>
2003-12-15  8:07   ` Joakim Hove
2003-12-15  8:46     ` Eli Zaretskii
2003-12-18  9:22 ` Brad Collins
     [not found] ` <mailman.242.1071742690.868.help-gnu-emacs@gnu.org>
2003-12-18 10:32   ` Kai Grossjohann
2003-12-18 17:30     ` Brad Collins
     [not found]     ` <mailman.280.1071771962.868.help-gnu-emacs@gnu.org>
2003-12-18 18:30       ` Harald Maier
2003-12-18 18:31       ` Kai Grossjohann

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=u7k0z8xjb.fsf@elta.co.il \
    --to=eliz@elta.co.il \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).