help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to create random characters?


From: Eli Zaretskii
Subject: Re: How to create random characters?
Date: 14 Dec 2003 13:10:48 +0200

> From: Brad Collins <address@hidden>
> 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 via email to

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