----- Original Message -----
From: "dazy" <dazy@xxxxxxx>
To: "prolog" <prolog@xxxxxxxxxxxxxx>
Sent: Tuesday, December 13, 2005 5:19 AM
Subject: [SWIPL] random/1
JF Dazy,
> Hi,
> why random/1 dont work on Version 5.5.38 ?
>
> the reference exist in help :
> random(+IntExpr)
> Evaluates to a random integer i for which 0=< i< IntExpr. The seed
> of this random generator is determined by the system clock when
> SWI-Prolog was started.
>
> 25 ?- random(100).
> ERROR: Undefined procedure: random/1
> 26 ?-
>
Try:
R is random(100).
Cheers,
Anthony Borla
P.S.
You may find the following useful:
:- arithmetic_function(random/3).
random(LB, UB, R) :-
AUB is UB - LB, AR is random(AUB), R is AR + LB.
Allows use [according to the documentation] either as:
?- random(5, 15, R).
or:
?- R is random(5, 15).
See SWI Help for more details.
|