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

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

Re: Random number generation in LISP or using it


From: bolega
Subject: Re: Random number generation in LISP or using it
Date: Wed, 10 Jun 2009 08:26:53 -0700 (PDT)
User-agent: G2/1.0

These are operations available via help in emacs but I dont know how
to use cl type operations in lisp defun.


*random-state*'s value is
[cl-random-state-tag -1 30 98807703]
Documentation:
not documented as a variable.
Defined in `cl'.


5x5-crack-randomly is an interactive autoloaded Lisp function in
`5x5'.
[Arg list not available until function definition is loaded.]
Attempt to crack 5x5 using random solutions.


cl-random-time is a compiled Lisp function in `cl'.
(cl-random-time)
not documented


make-random-state is an autoloaded Lisp function in `cl-extra'.
[Arg list not available until function definition is loaded.]
not documented


random is a built-in function.
(random &optional N)
Return a pseudo-random number.
All integers representable in Lisp are equally likely.
  On most systems, this is 28 bits' worth.
With positive integer argument N, return random number in interval
[0,N).
With argument t, set the random number seed from the current time and
pid.



On Jun 10, 8:21 am, bolega <gnuist...@gmail.com> wrote:
> I am a newbie with the following problem.
>
> A the outset let me state that the limitation is that I have to use
> this inside emacs to scramble a set of chosen lines like you do
> "reverse-region" or "sort-lines". It is possible that I can call some
> scheme or clisp functions.
>
> What is a fast(est) method to randomize lines based on the
> capabilities of emacs ?
>
> The function "random" does not work in emacs. I guess one get the
> 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 ?
>
> 1 -> 5
> 2 -> 8
> 3 -> 6
> 4 -> 9
> 5 -> 1
> 6 -> 3
> 7 -> 2
> 8 -> 7
> 9 -> 4
>
> and then use these pairs to reorder the lines. I guess there is a need
> for one or two variables to hold the lines, or just a kill or the top
> line and go down a certain number of random steps and paste it there ?
> Then come back to the top and do the same thing. The type of capacity
> I am looking is to randomize about few hundred short lines of about 20
> to 30 characters.
>
> 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.
>
> Thanks for any help.
> gnuist



reply via email to

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