- Documentation
- Reference manual
- Built-in Predicates
- Notation of Predicate Descriptions
- Character representation
- Loading Prolog source files
- Editor Interface
- Verify Type of a Term
- Comparison and Unification of Terms
- Control Predicates
- Meta-Call Predicates
- Delimited continuations
- Exception handling
- Printing messages
- Handling signals
- DCG Grammar rules
- Database
- Declaring predicate properties
- Examining the program
- Input and output
- Status of streams
- Primitive character I/O
- Term reading and writing
- Analysing and Constructing Terms
- Analysing and Constructing Atoms
- Localization (locale) support
- Character properties
- Operators
- Character Conversion
- Arithmetic
- Misc arithmetic support predicates
- Built-in list operations
- Finding all Solutions to a Goal
- Forall
- Formatted Write
- Global variables
- Terminal Control
- Operating System Interaction
- File System Interaction
- User Top-level Manipulation
- Creating a Protocol of the User Interaction
- Debugging and Tracing Programs
- Debugging and declaring determinism
- Obtaining Runtime Statistics
- Execution profiling
- Memory Management
- Windows DDE interface
- Miscellaneous
- Built-in Predicates
- Packages
- Reference manual
4.28 Misc arithmetic support predicates
- set_random(+Option)
- Controls the random number generator accessible through the
functions random/1
and random_float/0.
Note that the library
library(random)
provides an alternative API to the same random primitives.- seed(+Seed)
- Set the seed of the random generator for this thread. Seed is
an integer or the atom
random
. Ifrandom
, repeat the initialization procedure described with the function random/1. Here is an example:?- set_random(seed(111)), A is random(6). A = 5. ?- set_random(seed(111)), A is random(6). A = 5.
- state(+State)
- Set the generator to a state fetched using the state property of random_property/1. Using other values may lead to undefined behaviour.134The limitations of the underlying (GMP) library are unknown, which makes it impossible to validate the State.
- random_property(?Option)
- True when Option is a current property of the random
generator. Currently, this predicate provides access to the state. This
predicate is not present on systems where the state is inaccessible.
- state(-State)
- Describes the current state of the random generator. State is a normal
Prolog term that can be asserted or written to a file. Applications
should make no other assumptions about its representation. The only
meaningful operation is to use as argument to set_random/1
using the
state(State)
option.bugGMP provides no portable mechanism to fetch and restore the state. The current implementation works, but the state depends on the platform. I.e., it is generally not possible to reuse the state with another version of GMP or on a CPU with different datasizes or endian-ness.
- current_arithmetic_function(?Head)
- True when Head is an evaluable function. For example:
?- current_arithmetic_function(sin(_)). true.