@Darione wrote:
Hello,
i was trying to generate a random string.
Looking for something similar on google, i find this one way:Random.seed!( 0 ) prefix_result = randstring(12) println(prefix_result)
I understand that force seed to 0, Ialways get the same string, so I test in this way:
using Random println("--------------------------") #Random.seed!( rand(1:100000) ) prefix_result = randstring(12) println(prefix_result) Random.seed!( 0 ) prefix_result = randstring(12) println(prefix_result) Random.seed!( rand(1:100000) ) prefix_result = randstring(12) println(prefix_result)
And i obtein differe behavoiur in June and running as script from command line:
In june i get the same string, if i run again and again my scrip:
-------------------------- 6J6tq8qFzZvo 0IPrGg0JVONT Hw3AOmXRzOiv -------------------------- 6J6tq8qFzZvo 0IPrGg0JVONT Hw3AOmXRzOiv -------------------------- 6J6tq8qFzZvo 0IPrGg0JVONT Hw3AOmXRzOiv julia>
In the command line, i get this:
c:\vmswap\juliaPrj\querere>julia rand.jl -------------------------- BKKKCPvwjG86 0IPrGg0JVONT Hw3AOmXRzOiv c:\vmswap\juliaPrj\querere>julia rand.jl -------------------------- XKVf5RArKQMe 0IPrGg0JVONT Hw3AOmXRzOiv c:\vmswap\juliaPrj\querere>julia rand.jl -------------------------- SDKUTD3HG8S3 0IPrGg0JVONT Hw3AOmXRzOiv c:\vmswap\juliaPrj\querere>
I understand that i don’t have to set se seed if i want a random number every time (in the command line) … this is clear, ok, but I really do not understand why running in the juno REPL i get the same strings every time … what i am doing wrong?
Many thanks for reply.
Posts: 7
Participants: 3