Created the library random and moved some predicates from iso_ext
This commit is contained in:
16
src/prolog/lib/random.pl
Normal file
16
src/prolog/lib/random.pl
Normal file
@@ -0,0 +1,16 @@
|
||||
:- module(random, [maybe/0, set_random/1]).
|
||||
|
||||
% succeeds with probability 0.5.
|
||||
maybe :- '$maybe'.
|
||||
|
||||
set_random(Seed) :-
|
||||
( nonvar(Seed) ->
|
||||
( Seed = seed(S) ->
|
||||
( var(S) -> throw(error(instantiation_error, set_random/1))
|
||||
; integer(S) -> '$set_seed'(S)
|
||||
; throw(error(type_error(integer(S), set_random/1)))
|
||||
)
|
||||
)
|
||||
; throw(error(instantiation_error, set_random/1))
|
||||
).
|
||||
|
||||
Reference in New Issue
Block a user