lilypond-user
[Top][All Lists]
Advanced

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

Re: Random output in LilyPond Log


From: Freeman Gilmore
Subject: Re: Random output in LilyPond Log
Date: Thu, 12 Jul 2018 16:42:36 -0400



On Thu, Jul 12, 2018 at 4:15 PM, David Kastrup <address@hidden> wrote:
Karlin High <address@hidden> writes:

> On 7/12/2018 1:17 PM, Freeman Gilmore wrote:
>> I am using Frescobaldi and studying the Scheme Book.    When I compile,
>>
>> mylist = #( list 'red  random 12 )
>> #(display mylist)
>
> If this is an exercise to demonstrate random numbers, I wonder if it
> needs more parentheses.
>
> % CODE
> \version "2.19.80"
> mylist = #(list 'red (random 12))
> #(display mylist)
> % END CODE
>
> If I run it that way in Frescobaldi, it always returns: (red 3)
>
> If I use lilypond scheme-sandbox, I get things like this:
>
> guile> (list 'red (random 12))
> (red 3)
> guile> (list 'red (random 12))
> (red 4)

You could read the documentation for random.

       Note that the initial value of ‘*random-state*’ is the same every
    time Guile starts up.  Therefore, if you don’t pass a STATE parameter to
    the above procedures, and you don’t set ‘*random-state*’ to
    ‘(seed->random-state your-seed)’, where ‘your-seed’ is something that
    _isn’t_ the same every time, you’ll get the same sequence of “random”
    numbers on every run.

       For example, unless the relevant source code has changed, ‘(map
    random (cdr (iota 30)))’, if the first use of random numbers since Guile
    started up, will always give:

         (map random (cdr (iota 19)))
         ⇒
         (0 1 1 2 2 2 1 2 6 7 10 0 5 3 12 5 5 12)

       To seed the random state in a sensible way for non-security-critical
    applications, do this during initialization of your program:

         (set! *random-state* (random-state-from-platform))



--
David Kastrup
​David:

​"random" has nothing to go with it, replace it with a different procedure ​I.e. "display" and it will do the same thing.

Thank you,ƒg
 


reply via email to

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