When executing the following Prolog program with YAP, the output is always the same, namely the integer 233.
:- use_module(library(random)).
x:- random(1,1000,X), writeln(X).
For instance, if I execute the following bash script, the output is always the same integer (233).
for k in `seq 0`
do
yap -l test.pl << %
x.
%
done
If I repeat this procedure using swipl, then the output is different each time, i.e random.
Can anyone explain this?
usually, random generators require something like set_seed(SomeReallyRandomValue) call, in C was often used seed(time(0)). So, I guess
datime(datime(_Year, _Month, _DayOfTheMonth, _Hour, Minute, Second)),
X is Minute * Second,Y=X,Z=X,
setrand(rand(X,Y,Z)),
could work