lua-users home
lua-l archive

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


I don't think it worked. I got the following output:

wutwut =0.1883697509765625
wutwut =0
wutwut =0.1883697509765625


Mike


On Mon, Sep 9, 2013 at 8:24 PM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> On 10/09/2013, at 12:17 PM, Michael Horvath <mikh2161@gmail.com> wrote:
>
>> I found this set of pseudo random number generators here:
>> ...
>> print("wutwut =" .. lcg(0):random())
>> print("wutwut =" .. lcg(0):random())
>> print("wutwut =" .. lcg(0):random())
>>
>> However, the output is always the same number. What am I doing wrong?
>
> You're creating a new generator on each line.  Try (untested):
>
> local R = lcg(0)
> print("wutwut =" .. R:random())
> print("wutwut =" .. R:random())
> print("wutwut =" .. R:random())
>
> (Also, please don't send HTML email, the list prefers plain text)
>