The cl-pcg Reference Manual

This is the cl-pcg Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 15:33:52 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-pcg

A bare-bones Permuted Congruential Generator implementation in pure Common Lisp.

Author

Steve Losh <>

Home Page

https://docs.stevelosh.com/cl-pcg/

License

MIT

Version

1.0.0

Dependency

sb-rotate-byte (system).

Source

cl-pcg.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 cl-pcg/vendor

Source

cl-pcg.asd.

Parent Component

cl-pcg (system).

Child Components

3.2 cl-pcg/src

Dependency

package.lisp (file).

Source

cl-pcg.asd.

Parent Component

cl-pcg (system).

Child Component

pcg.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 cl-pcg/cl-pcg.asd

Source

cl-pcg.asd.

Parent Component

cl-pcg (system).

ASDF Systems

cl-pcg.


4.1.2 cl-pcg/vendor/quickutils-package.lisp

Source

cl-pcg.asd.

Parent Component

vendor (module).

Packages

pcg.quickutils.

Internals

*utilities* (special variable).


4.1.3 cl-pcg/vendor/quickutils.lisp

Dependency

quickutils-package.lisp (file).

Source

cl-pcg.asd.

Parent Component

vendor (module).

Public Interface
Internals

4.1.4 cl-pcg/package.lisp

Dependency

vendor (module).

Source

cl-pcg.asd.

Parent Component

cl-pcg (system).

Packages

pcg.


4.1.5 cl-pcg/src/pcg.lisp

Source

cl-pcg.asd.

Parent Component

src (module).

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 pcg.quickutils

Package that contains Quickutil utility functions.

Source

quickutils-package.lisp.

Use List

common-lisp.

Used By List

pcg.

Public Interface
Internals

5.2 pcg

Source

package.lisp.

Use List
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Macros

Macro: with-gensyms (names &body forms)

Binds each variable named by a symbol in ‘names‘ to a unique symbol around ‘forms‘. Each of ‘names‘ must either be either a symbol, or of the form:

(symbol string-designator)

Bare symbols appearing in ‘names‘ are equivalent to:

(symbol symbol)

The string-designator is used as the argument to ‘gensym‘ when constructing the unique symbol the named variable will be bound to.

Package

pcg.quickutils.

Source

quickutils.lisp.

Macro: with-unique-names (names &body forms)

Binds each variable named by a symbol in ‘names‘ to a unique symbol around ‘forms‘. Each of ‘names‘ must either be either a symbol, or of the form:

(symbol string-designator)

Bare symbols appearing in ‘names‘ are equivalent to:

(symbol symbol)

The string-designator is used as the argument to ‘gensym‘ when constructing the unique symbol the named variable will be bound to.

Package

pcg.quickutils.

Source

quickutils.lisp.


6.1.2 Ordinary functions

Function: make-pcg (&key seed stream-id)

Create and return a new PCG.

If ‘seed‘ is ‘nil‘, a fresh random seed will be generated with the implementation’s ‘cl:random‘ function, as if by:

(random ... (make-random-state t))

Package

pcg.

Source

pcg.lisp.

Function: make-pcg% (seed stream-id)

Create and return a new ‘pcg‘ for the given ‘seed‘ and ‘stream-id‘.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: pcg-advance (pcg steps)

Advance the state of ‘pcg‘ by ‘steps‘ steps.

This function returns ‘nil‘ and is only useful for its side effects.

Package

pcg.

Source

pcg.lisp.

Function: pcg-advance% (pcg steps)

Advance the state of ‘pcg‘ by ‘steps‘ steps.

This function returns ‘nil‘ and is only useful for its side effects.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random (pcg bound &optional max inclusive?)

Generate and return a random number in the specified interval.

If ‘max‘ is omitted the interval will be ‘[0, bound)‘.

If ‘max‘ is given the interval will be ‘[bound, max)‘.

If ‘inclusive?‘ is given the interval will be ‘[bound, max]‘.

If either of ‘bound‘ or ‘max‘ are floats, the result will be a float. Otherwise the result will be an integer.

As a side effect, the state of ‘pcg‘ will be advanced.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random% (pcg)

Return a random ‘(unsigned-byte 32)‘.

As a side effect, the state of ‘pcg‘ will be advanced.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random-bounded% (pcg bound)

Return a random integer between ‘0‘ (inclusive) and ‘bound‘ (exclusive).

As a side effect, the state of ‘pcg‘ will be advanced.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random-float% (pcg)

Return a random ‘single-float‘ between ‘0.0‘ and ‘1.0‘.

As a side effect, the state of ‘pcg‘ will be advanced.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: pcg-rewind (pcg steps)

Rewind the state of ‘pcg‘ by ‘steps‘ steps.

This function returns ‘nil‘ and is only useful for its side effects.

Package

pcg.

Source

pcg.lisp.

Function: pcg-rewind% (pcg steps)

Rewind the state of ‘pcg‘ by ‘steps‘ steps.

This function returns ‘nil‘ and is only useful for its side effects.

This is a low-level function that assumes you are passing in the correct types.

Package

pcg.

Source

pcg.lisp.

Function: symb (&rest args)

Receives any number of objects, concatenates all into one string with ‘#’mkstr‘ and converts them to symbol.

Extracted from _On Lisp_, chapter 4.

See also: ‘symbolicate‘

Package

pcg.quickutils.

Source

quickutils.lisp.


6.1.3 Structures

Structure: pcg
Package

pcg.

Source

pcg.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: state
Type

pcg::u64

Initform

0

Readers

pcg-state.

Writers

(setf pcg-state).

Slot: increment
Type

pcg::u64

Initform

0

Readers

pcg-increment.

Writers

(setf pcg-increment).


6.2 Internals


6.2.1 Constants

Constant: +limit+
Package

pcg.

Source

pcg.lisp.

Constant: +modulus+
Package

pcg.

Source

pcg.lisp.

Constant: +multiplier+
Package

pcg.

Source

pcg.lisp.


6.2.2 Special variables

Special Variable: *global-generator*
Package

pcg.

Source

pcg.lisp.

Special Variable: *utilities*
Package

pcg.quickutils.

Source

quickutils-package.lisp.


6.2.3 Macros

Macro: check-types (&rest place-type-pairs)
Package

pcg.

Source

pcg.lisp.

Macro: defun-inline (name &body body)

Like ‘defun‘, but declaims ‘name‘ to be ‘inline‘.

Package

pcg.

Source

pcg.lisp.


6.2.4 Ordinary functions

Function: % (n)
Package

pcg.

Source

pcg.lisp.

Function: *+ (a b increment)
Package

pcg.

Source

pcg.lisp.

Function: actually-make-pcg (&key state increment)
Package

pcg.

Source

pcg.lisp.

Function: advance-state (pcg)
Package

pcg.

Source

pcg.lisp.

Function: compute-increment (stream-id)
Package

pcg.

Source

pcg.lisp.

Function: copy-pcg (instance)
Package

pcg.

Source

pcg.lisp.

Function: mkstr (&rest args)

Receives any number of objects (string, symbol, keyword, char, number), extracts all printed representations, and concatenates them all into one string.

Extracted from _On Lisp_, chapter 4.

Package

pcg.quickutils.

Source

quickutils.lisp.

Reader: pcg-increment (instance)
Writer: (setf pcg-increment) (instance)
Package

pcg.

Source

pcg.lisp.

Target Slot

increment.

Function: pcg-p (object)
Package

pcg.

Source

pcg.lisp.

Function: pcg-random-float (pcg min max)

Return a random ‘single-float‘.

As a side effect, the state of ‘pcg‘ will be advanced.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random-integer (pcg min max)

Return a random integer.

As a side effect, the state of ‘pcg‘ will be advanced.

Package

pcg.

Source

pcg.lisp.

Function: pcg-random-range% (pcg min max)
Package

pcg.

Source

pcg.lisp.

Reader: pcg-state (instance)
Writer: (setf pcg-state) (instance)
Package

pcg.

Source

pcg.lisp.

Target Slot

state.

Function: permute-rotate (data selector)
Package

pcg.

Source

pcg.lisp.

Function: permute-xor-shift (data)
Package

pcg.

Source

pcg.lisp.

Function: resolve-pcg (pcg-designator)
Package

pcg.

Source

pcg.lisp.

Function: resolve-seed (seed)
Package

pcg.

Source

pcg.lisp.

Function: rotate-byte (count bytespec integer)

Rotates a field of bits within INTEGER; specifically, returns an integer that contains the bits of INTEGER rotated COUNT times leftwards within the byte specified by BYTESPEC, and elsewhere contains the bits of INTEGER. See http://www.cliki.net/ROTATE-BYTE

Package

pcg.

Source

pcg.lisp.


6.2.5 Types

Type: pcg-designator ()
Package

pcg.

Source

pcg.lisp.

Type: string-designator ()

A string designator type. A string designator is either a string, a symbol, or a character.

Package

pcg.quickutils.

Source

quickutils.lisp.

Type: u32 ()
Package

pcg.

Source

pcg.lisp.

Type: u64 ()
Package

pcg.

Source

pcg.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (   *  
A   C   D   F   M   P   R   S   W  
Index Entry  Section

%
%: Private ordinary functions

(
(setf pcg-increment): Private ordinary functions
(setf pcg-state): Private ordinary functions

*
*+: Private ordinary functions

A
actually-make-pcg: Private ordinary functions
advance-state: Private ordinary functions

C
check-types: Private macros
compute-increment: Private ordinary functions
copy-pcg: Private ordinary functions

D
defun-inline: Private macros

F
Function, %: Private ordinary functions
Function, (setf pcg-increment): Private ordinary functions
Function, (setf pcg-state): Private ordinary functions
Function, *+: Private ordinary functions
Function, actually-make-pcg: Private ordinary functions
Function, advance-state: Private ordinary functions
Function, compute-increment: Private ordinary functions
Function, copy-pcg: Private ordinary functions
Function, make-pcg: Public ordinary functions
Function, make-pcg%: Public ordinary functions
Function, mkstr: Private ordinary functions
Function, pcg-advance: Public ordinary functions
Function, pcg-advance%: Public ordinary functions
Function, pcg-increment: Private ordinary functions
Function, pcg-p: Private ordinary functions
Function, pcg-random: Public ordinary functions
Function, pcg-random%: Public ordinary functions
Function, pcg-random-bounded%: Public ordinary functions
Function, pcg-random-float: Private ordinary functions
Function, pcg-random-float%: Public ordinary functions
Function, pcg-random-integer: Private ordinary functions
Function, pcg-random-range%: Private ordinary functions
Function, pcg-rewind: Public ordinary functions
Function, pcg-rewind%: Public ordinary functions
Function, pcg-state: Private ordinary functions
Function, permute-rotate: Private ordinary functions
Function, permute-xor-shift: Private ordinary functions
Function, resolve-pcg: Private ordinary functions
Function, resolve-seed: Private ordinary functions
Function, rotate-byte: Private ordinary functions
Function, symb: Public ordinary functions

M
Macro, check-types: Private macros
Macro, defun-inline: Private macros
Macro, with-gensyms: Public macros
Macro, with-unique-names: Public macros
make-pcg: Public ordinary functions
make-pcg%: Public ordinary functions
mkstr: Private ordinary functions

P
pcg-advance: Public ordinary functions
pcg-advance%: Public ordinary functions
pcg-increment: Private ordinary functions
pcg-p: Private ordinary functions
pcg-random: Public ordinary functions
pcg-random%: Public ordinary functions
pcg-random-bounded%: Public ordinary functions
pcg-random-float: Private ordinary functions
pcg-random-float%: Public ordinary functions
pcg-random-integer: Private ordinary functions
pcg-random-range%: Private ordinary functions
pcg-rewind: Public ordinary functions
pcg-rewind%: Public ordinary functions
pcg-state: Private ordinary functions
permute-rotate: Private ordinary functions
permute-xor-shift: Private ordinary functions

R
resolve-pcg: Private ordinary functions
resolve-seed: Private ordinary functions
rotate-byte: Private ordinary functions

S
symb: Public ordinary functions

W
with-gensyms: Public macros
with-unique-names: Public macros