Package coalton
Public interface to COALTON.
fixed-size-numbers.lisp
Types
I8
[TYPE]
Signed 8-bit integer capable of storing values in [-128, 127]
. Uses (signed-byte 8)
.
Instances
BITS I8
RUNTIMEREPR I8
EQ I8
NUM I8
ORD I8
HASH I8
INTO I8 DOUBLE-FLOAT
INTO I8 SINGLE-FLOAT
INTO I8 INTEGER
INTO I8 IFIX
INTO I8 I64
INTO I8 I32
INTO I8 I16
TRYINTO INTEGER I8
TRYINTO IFIX I8
TRYINTO UFIX I8
TRYINTO I64 I8
TRYINTO U64 I8
TRYINTO I32 I8
TRYINTO U32 I8
TRYINTO I16 I8
TRYINTO U16 I8
TRYINTO I8 UFIX
TRYINTO I8 U64
TRYINTO I8 U32
TRYINTO I8 U16
TRYINTO I8 U8
TRYINTO U8 I8
REAL I8
RATIONAL I8
QUANTIZABLE I8
BOUNDED I8
COMPLEX I8
INTEGRAL I8
REMAINDER I8
U8
[TYPE]
Unsigned 8-bit integer capable of storing values in [0, 255]
. Uses (unsigned-byte 8)
.
Instances
BITS U8
RUNTIMEREPR U8
EQ U8
NUM U8
ORD U8
HASH U8
INTO U8 DOUBLE-FLOAT
INTO U8 SINGLE-FLOAT
INTO U8 INTEGER
INTO U8 IFIX
INTO U8 UFIX
INTO U8 I64
INTO U8 U64
INTO U8 I32
INTO U8 U32
INTO U8 I16
INTO U8 U16
TRYINTO INTEGER U8
TRYINTO IFIX U8
TRYINTO UFIX U8
TRYINTO I64 U8
TRYINTO U64 U8
TRYINTO I32 U8
TRYINTO U32 U8
TRYINTO I16 U8
TRYINTO U16 U8
TRYINTO I8 U8
TRYINTO U8 I8
REAL U8
RATIONAL U8
QUANTIZABLE U8
BOUNDED U8
COMPLEX U8
INTEGRAL U8
REMAINDER U8
I16
[TYPE]
Signed 16-bit integer capable of storing values in [-32768, 32767]
. Uses (signed-byte 16)
.
Instances
BITS I16
RUNTIMEREPR I16
EQ I16
NUM I16
ORD I16
HASH I16
INTO I16 DOUBLE-FLOAT
INTO I16 SINGLE-FLOAT
INTO I16 INTEGER
INTO I16 IFIX
INTO I16 I64
INTO I16 I32
INTO I8 I16
INTO U8 I16
TRYINTO INTEGER I16
TRYINTO IFIX I16
TRYINTO UFIX I16
TRYINTO I64 I16
TRYINTO U64 I16
TRYINTO I32 I16
TRYINTO U32 I16
TRYINTO I16 UFIX
TRYINTO I16 U64
TRYINTO I16 U32
TRYINTO I16 U16
TRYINTO I16 I8
TRYINTO I16 U8
TRYINTO U16 I16
BOUNDED I16
COMPLEX I16
INTEGRAL I16
REMAINDER I16
I32
[TYPE]
Signed 32-bit integer capable of storing values in [-2147483648, 2147483647]
. Uses (signed-byte 32)
.
Instances
BITS I32
RUNTIMEREPR I32
EQ I32
NUM I32
ORD I32
HASH I32
INTO I32 DOUBLE-FLOAT
INTO I32 INTEGER
INTO I32 IFIX
INTO I32 I64
INTO I16 I32
INTO U16 I32
INTO I8 I32
INTO U8 I32
TRYINTO INTEGER I32
TRYINTO IFIX I32
TRYINTO UFIX I32
TRYINTO I64 I32
TRYINTO U64 I32
TRYINTO I32 UFIX
TRYINTO I32 U64
TRYINTO I32 U32
TRYINTO I32 I16
TRYINTO I32 U16
TRYINTO I32 I8
TRYINTO I32 U8
TRYINTO U32 I32
REAL I32
RATIONAL I32
QUANTIZABLE I32
BOUNDED I32
COMPLEX I32
INTEGRAL I32
REMAINDER I32
I64
[TYPE]
Signed 64-bit integer capable of storing values in [-9223372036854775808, 9223372036854775807]
. Uses (signed-byte 64)
.
Instances
BITS I64
RUNTIMEREPR I64
EQ I64
NUM I64
ORD I64
HASH I64
INTO IFIX I64
INTO UFIX I64
INTO I64 INTEGER
INTO I32 I64
INTO U32 I64
INTO I16 I64
INTO U16 I64
INTO I8 I64
INTO U8 I64
TRYINTO INTEGER I64
TRYINTO I64 IFIX
TRYINTO I64 UFIX
TRYINTO I64 U64
TRYINTO I64 I32
TRYINTO I64 U32
TRYINTO I64 I16
TRYINTO I64 U16
TRYINTO I64 I8
TRYINTO I64 U8
TRYINTO U64 I64
REAL I64
RATIONAL I64
QUANTIZABLE I64
BOUNDED I64
COMPLEX I64
INTEGRAL I64
REMAINDER I64
U16
[TYPE]
Unsigned 16-bit integer capable of storing values in [0, 65535]
. Uses (unsigned-byte 16)
.
Instances
BITS U16
RUNTIMEREPR U16
EQ U16
NUM U16
ORD U16
HASH U16
INTO U16 DOUBLE-FLOAT
INTO U16 SINGLE-FLOAT
INTO U16 INTEGER
INTO U16 IFIX
INTO U16 UFIX
INTO U16 I64
INTO U16 U64
INTO U16 I32
INTO U16 U32
INTO U8 U16
TRYINTO INTEGER U16
TRYINTO IFIX U16
TRYINTO UFIX U16
TRYINTO I64 U16
TRYINTO U64 U16
TRYINTO I32 U16
TRYINTO U32 U16
TRYINTO I16 U16
TRYINTO U16 I16
TRYINTO U16 I8
TRYINTO U16 U8
TRYINTO I8 U16
BOUNDED U16
COMPLEX U16
INTEGRAL U16
REMAINDER U16
U32
[TYPE]
Unsigned 32-bit integer capable of storing values in [0, 4294967295]
. Uses (unsigned-byte 32)
.
Instances
BITS U32
RUNTIMEREPR U32
EQ U32
NUM U32
ORD U32
HASH U32
INTO U32 DOUBLE-FLOAT
INTO U32 INTEGER
INTO U32 IFIX
INTO U32 UFIX
INTO U32 I64
INTO U32 U64
INTO U16 U32
INTO U8 U32
TRYINTO INTEGER U32
TRYINTO IFIX U32
TRYINTO UFIX U32
TRYINTO I64 U32
TRYINTO U64 U32
TRYINTO I32 U32
TRYINTO U32 I32
TRYINTO U32 I16
TRYINTO U32 U16
TRYINTO U32 I8
TRYINTO U32 U8
TRYINTO I16 U32
TRYINTO I8 U32
REAL U32
RATIONAL U32
QUANTIZABLE U32
BOUNDED U32
COMPLEX U32
INTEGRAL U32
REMAINDER U32
U64
[TYPE]
Unsigned 64-bit integer capable of storing values in [0, 18446744073709551615]
. Uses (unsigned-byte 64)
.
Instances
BITS U64
RUNTIMEREPR U64
EQ U64
NUM U64
ORD U64
HASH U64
INTO UFIX U64
INTO U64 INTEGER
INTO U32 U64
INTO U16 U64
INTO U8 U64
TRYINTO INTEGER U64
TRYINTO IFIX U64
TRYINTO I64 U64
TRYINTO U64 IFIX
TRYINTO U64 UFIX
TRYINTO U64 I64
TRYINTO U64 I32
TRYINTO U64 U32
TRYINTO U64 I16
TRYINTO U64 U16
TRYINTO U64 I8
TRYINTO U64 U8
TRYINTO I32 U64
TRYINTO I16 U64
TRYINTO I8 U64
REAL U64
RATIONAL U64
QUANTIZABLE U64
BOUNDED U64
COMPLEX U64
INTEGRAL U64
REMAINDER U64
IFIX
[TYPE]
Non-allocating tagged integer; range is platform-dependent. Does not error on overflow. Uses fixnum
.
Instances
BITS IFIX
RUNTIMEREPR IFIX
EQ IFIX
NUM IFIX
ORD IFIX
HASH IFIX
INTO IFIX INTEGER
INTO IFIX I64
INTO UFIX IFIX
INTO I32 IFIX
INTO U32 IFIX
INTO I16 IFIX
INTO U16 IFIX
INTO I8 IFIX
INTO U8 IFIX
TRYINTO INTEGER IFIX
TRYINTO IFIX UFIX
TRYINTO IFIX U64
TRYINTO IFIX I32
TRYINTO IFIX U32
TRYINTO IFIX I16
TRYINTO IFIX U16
TRYINTO IFIX I8
TRYINTO IFIX U8
TRYINTO I64 IFIX
TRYINTO U64 IFIX
REAL IFIX
RATIONAL IFIX
QUANTIZABLE IFIX
BOUNDED IFIX
COMPLEX IFIX
INTEGRAL IFIX
REMAINDER IFIX
UFIX
[TYPE]
Non-allocating tagged non-negative integer; range is platform-dependent. Uses (and fixnum unsigned-byte)
.
Instances
BITS UFIX
RUNTIMEREPR UFIX
EQ UFIX
NUM UFIX
ORD UFIX
HASH UFIX
INTO UFIX INTEGER
INTO UFIX IFIX
INTO UFIX I64
INTO UFIX U64
INTO U32 UFIX
INTO U16 UFIX
INTO U8 UFIX
TRYINTO INTEGER UFIX
TRYINTO IFIX UFIX
TRYINTO UFIX I32
TRYINTO UFIX U32
TRYINTO UFIX I16
TRYINTO UFIX U16
TRYINTO UFIX I8
TRYINTO UFIX U8
TRYINTO I64 UFIX
TRYINTO U64 UFIX
TRYINTO I32 UFIX
TRYINTO I16 UFIX
TRYINTO I8 UFIX
REAL UFIX
RATIONAL UFIX
QUANTIZABLE UFIX
BOUNDED UFIX
COMPLEX UFIX
INTEGRAL UFIX
REMAINDER UFIX
classes.lisp
Types
UNIT
[TYPE]
UNIT
Instances
VOID
[TYPE]
Instances
Types
CHAR
[TYPE]
A single character represented as a character
type.
LIST :A
[TYPE]
(CONS :A (LIST :A))
NIL
Homogeneous list of objects represented as a Common Lisp list
.
Instances
RUNTIMEREPR (LIST :A)
EQ :A ⇒ EQ (LIST :A)
RUNTIMEREPR :A ⇒ ISO (VECTOR :A) (LIST :A)
ISO (LIST CHAR) STRING
ORD :A ⇒ ORD (LIST :A)
HASH :A ⇒ HASH (LIST :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (LIST :A)
RUNTIMEREPR :A ⇒ INTO (LIST :A) (VECTOR :A)
INTO (LIST CHAR) STRING
INTO STRING (LIST CHAR)
MONAD LIST
MONOID (LIST :A)
FUNCTOR LIST
FOLDABLE LIST
SEMIGROUP (LIST :A)
ADDRESSABLE (LIST :A)
ALTERNATIVE LIST
APPLICATIVE LIST
TRAVERSABLE LIST
FROMITERATOR (LIST :A) :A
INTOITERATOR (LIST :A) :A
ARROW :A :B
[TYPE]
Type constructor for function types.
Instances
RUNTIMEREPR (:A → :B)
STRING
[TYPE]
String of characters represented by Common Lisp string
.
Instances
BOOLEAN
[TYPE]
FALSE
TRUE
Either true or false represented by t
and nil
respectively.
INTEGER
[TYPE]
Unbound integer. Uses integer
.
Instances
BITS INTEGER
RUNTIMEREPR INTEGER
EQ INTEGER
NUM INTEGER
ORD INTEGER
HASH INTEGER
INTO INTEGER BIG-FLOAT
INTO INTEGER STRING
INTO INTEGER DYADIC
INTO IFIX INTEGER
INTO UFIX INTEGER
INTO I64 INTEGER
INTO U64 INTEGER
INTO I32 INTEGER
INTO U32 INTEGER
INTO I16 INTEGER
INTO U16 INTEGER
INTO I8 INTEGER
INTO U8 INTEGER
TRYINTO STRING INTEGER
TRYINTO INTEGER DOUBLE-FLOAT
TRYINTO INTEGER SINGLE-FLOAT
TRYINTO INTEGER IFIX
TRYINTO INTEGER UFIX
TRYINTO INTEGER I64
TRYINTO INTEGER U64
TRYINTO INTEGER I32
TRYINTO INTEGER U32
TRYINTO INTEGER I16
TRYINTO INTEGER U16
TRYINTO INTEGER I8
TRYINTO INTEGER U8
REAL INTEGER
RATIONAL INTEGER
QUANTIZABLE INTEGER
DIVIDABLE INTEGER BIG-FLOAT
DIVIDABLE INTEGER FRACTION
DIVIDABLE INTEGER DOUBLE-FLOAT
DIVIDABLE INTEGER SINGLE-FLOAT
COMPLEX INTEGER
INTEGRAL INTEGER
REMAINDER INTEGER
FRACTION
[TYPE]
A ratio of integers always in reduced form.
Instances
DOUBLE-FLOAT
[TYPE]
Double precision floating point numer. Uses double-float
.
Instances
RUNTIMEREPR DOUBLE-FLOAT
EQ DOUBLE-FLOAT
NUM DOUBLE-FLOAT
ORD DOUBLE-FLOAT
HASH DOUBLE-FLOAT
INTO DOUBLE-FLOAT BIG-FLOAT
INTO DOUBLE-FLOAT STRING
INTO I32 DOUBLE-FLOAT
INTO U32 DOUBLE-FLOAT
INTO I16 DOUBLE-FLOAT
INTO U16 DOUBLE-FLOAT
INTO I8 DOUBLE-FLOAT
INTO U8 DOUBLE-FLOAT
TRYINTO INTEGER DOUBLE-FLOAT
TRYINTO DOUBLE-FLOAT FRACTION
REAL DOUBLE-FLOAT
RATIONAL DOUBLE-FLOAT
QUANTIZABLE DOUBLE-FLOAT
DIVIDABLE INTEGER DOUBLE-FLOAT
TRANSFINITE DOUBLE-FLOAT
RECIPROCABLE DOUBLE-FLOAT
COMPLEX DOUBLE-FLOAT
POLAR DOUBLE-FLOAT
RADICAL DOUBLE-FLOAT
ELEMENTARY DOUBLE-FLOAT
EXPONENTIABLE DOUBLE-FLOAT
TRIGONOMETRIC DOUBLE-FLOAT
SINGLE-FLOAT
[TYPE]
Single precision floating point numer. Uses single-float
.
Instances
RUNTIMEREPR SINGLE-FLOAT
EQ SINGLE-FLOAT
NUM SINGLE-FLOAT
ORD SINGLE-FLOAT
HASH SINGLE-FLOAT
INTO SINGLE-FLOAT BIG-FLOAT
INTO SINGLE-FLOAT STRING
INTO I16 SINGLE-FLOAT
INTO U16 SINGLE-FLOAT
INTO I8 SINGLE-FLOAT
INTO U8 SINGLE-FLOAT
TRYINTO INTEGER SINGLE-FLOAT
TRYINTO SINGLE-FLOAT FRACTION
REAL SINGLE-FLOAT
RATIONAL SINGLE-FLOAT
QUANTIZABLE SINGLE-FLOAT
DIVIDABLE INTEGER SINGLE-FLOAT
TRANSFINITE SINGLE-FLOAT
RECIPROCABLE SINGLE-FLOAT
COMPLEX SINGLE-FLOAT
POLAR SINGLE-FLOAT
RADICAL SINGLE-FLOAT
ELEMENTARY SINGLE-FLOAT
EXPONENTIABLE SINGLE-FLOAT
TRIGONOMETRIC SINGLE-FLOAT
Package coalton-library/classes
classes.lisp
Types
ORD
[TYPE]
LT
GT
EQ
The result of an ordered comparison.
Instances
TUPLE :A :B
[TYPE]
(TUPLE :A :B)
A heterogeneous collection of items.
Instances
RUNTIMEREPR (TUPLE :A :B)
(EQ :A) (EQ :B) ⇒ EQ (TUPLE :A :B)
ISO (TUPLE :A :B) (TUPLE :B :A)
(ORD :A) (ORD :B) ⇒ ORD (TUPLE :A :B)
(HASH :A) (HASH :B) ⇒ HASH (TUPLE :A :B)
INTO (MAPPAIR :A :B) (TUPLE :A :B)
INTO (TUPLE :A :B) (TUPLE :B :A)
BIFUNCTOR TUPLE
ORD :A ⇒ FROMITERATOR (MAP :A :B) (TUPLE :A :B)
HASH :A ⇒ FROMITERATOR (HASHTABLE :A :B) (TUPLE :A :B)
INTOITERATOR (MAP :A :B) (TUPLE :A :B)
RESULT :A :B
[TYPE]
(ERR :A)
(OK :B)
Represents something that may have failed.
Instances
RUNTIMEREPR (RESULT :A :B)
(EQ :A) (EQ :B) ⇒ EQ (RESULT :A :B)
ISO (RESULT UNIT :A) (OPTIONAL :A)
(ORD :A) (ORD :B) ⇒ ORD (RESULT :A :B)
INTO (OPTIONAL :A) (RESULT UNIT :A)
INTO (RESULT :A :B) (OPTIONAL :B)
MONAD (RESULT :A)
MONOID :A ⇒ MONOID (RESULT :B :A)
FUNCTOR (RESULT :A)
BIFUNCTOR RESULT
SEMIGROUP :A ⇒ SEMIGROUP (RESULT :B :A)
APPLICATIVE (RESULT :A)
UNWRAPPABLE (RESULT :A)
INTOITERATOR (RESULT :A :B) :B
OPTIONAL :A
[TYPE]
(SOME :A)
NONE
Represents something that may not have a value.
Instances
RUNTIMEREPR (OPTIONAL :A)
EQ :A ⇒ EQ (OPTIONAL :A)
ISO (RESULT UNIT :A) (OPTIONAL :A)
NUM :A ⇒ NUM (OPTIONAL :A)
ORD :A ⇒ ORD (OPTIONAL :A)
INTO (OPTIONAL :A) (RESULT UNIT :A)
INTO (RESULT :A :B) (OPTIONAL :B)
MONAD OPTIONAL
MONOID :A ⇒ MONOID (OPTIONAL :A)
FUNCTOR OPTIONAL
MONADFAIL OPTIONAL
SEMIGROUP :A ⇒ SEMIGROUP (OPTIONAL :A)
ALTERNATIVE OPTIONAL
APPLICATIVE OPTIONAL
UNWRAPPABLE OPTIONAL
INTOITERATOR (OPTIONAL :A) :A
Classes
EQ
[CLASS]
EQ :A
Types which have equality defined.
Methods:
== :: (:A → :A → BOOLEAN)
Instances
EQ LISPTYPE
EQ UNIT
EQ ORD
EQ BOOLEAN
EQ U8
EQ U16
EQ U32
EQ U64
EQ I8
EQ I16
EQ I32
EQ I64
EQ INTEGER
EQ FRACTION
EQ IFIX
EQ UFIX
EQ SINGLE-FLOAT
EQ DOUBLE-FLOAT
COMPLEX :A ⇒ EQ (COMPLEX :A)
EQ DYADIC
EQ CHAR
EQ STRING
(EQ :A) (EQ :B) ⇒ EQ (TUPLE :A :B)
(EQ :A) (EQ :B) (EQ :C) ⇒ EQ (TUPLE3 :A :B :C)
(EQ :A) (EQ :B) (EQ :C) (EQ :D) ⇒ EQ (TUPLE4 :A :B :C :D)
(EQ :A) (EQ :B) (EQ :C) (EQ :D) (EQ :E) ⇒ EQ (TUPLE5 :A :B :C :D :E)
EQ :A ⇒ EQ (OPTIONAL :A)
EQ :A ⇒ EQ (LIST :A)
(EQ :A) (EQ :B) ⇒ EQ (RESULT :A :B)
EQ :A ⇒ EQ (CELL :A)
EQ :A ⇒ EQ (VECTOR :A)
EQ :A ⇒ EQ (SLICE :A)
EQ COLOR
EQ :A ⇒ EQ (TREE :A)
EQ :A ⇒ EQ (MAPPAIR :A :B)
(EQ :A) (EQ :B) ⇒ EQ (MAP :A :B)
EQ BIG-FLOAT
ISO
[CLASS]
(INTO :A :B) (INTO :B :A) ⇒ ISO :A :B
Opting into this marker typeclass imples that the instances for (Into :a :b) and (Into :b :a) form a bijection.
Methods:
Instances
NUM
[CLASS]
Types which have numeric operations defined.
Methods:
+ :: (:A → :A → :A)
- :: (:A → :A → :A)
* :: (:A → :A → :A)
FROMINT :: (INTEGER → :A)
Instances
ORD
[CLASS]
Types whose values can be ordered.
Methods:
<=> :: (:A → :A → ORD)
Instances
ORD ORD
ORD BOOLEAN
ORD U8
ORD U16
ORD U32
ORD U64
ORD I8
ORD I16
ORD I32
ORD I64
ORD INTEGER
ORD FRACTION
ORD IFIX
ORD UFIX
ORD SINGLE-FLOAT
ORD DOUBLE-FLOAT
ORD DYADIC
ORD CHAR
ORD STRING
(ORD :A) (ORD :B) ⇒ ORD (TUPLE :A :B)
ORD :A ⇒ ORD (OPTIONAL :A)
ORD :A ⇒ ORD (LIST :A)
(ORD :A) (ORD :B) ⇒ ORD (RESULT :A :B)
ORD :A ⇒ ORD (MAPPAIR :A :B)
ORD BIG-FLOAT
HASH
[CLASS]
Types which can be hashed for storage in hash tables.
Invariant (== left right) implies (== (hash left) (hash right)).
Methods:
HASH :: (:A → UFIX)
Instances
HASH BOOLEAN
HASH I8
HASH I16
HASH I32
HASH I64
HASH U8
HASH U16
HASH U32
HASH U64
HASH INTEGER
HASH IFIX
HASH UFIX
HASH SINGLE-FLOAT
HASH DOUBLE-FLOAT
HASH CHAR
HASH STRING
(HASH :A) (HASH :B) ⇒ HASH (TUPLE :A :B)
(HASH :A) (HASH :B) (HASH :C) ⇒ HASH (TUPLE3 :A :B :C)
(HASH :A) (HASH :B) (HASH :C) (HASH :D) ⇒ HASH (TUPLE4 :A :B :C :D)
(HASH :A) (HASH :B) (HASH :C) (HASH :D) (HASH :E) ⇒ HASH (TUPLE5 :A :B :C :D :E)
HASH :A ⇒ HASH (LIST :A)
HASH :A ⇒ HASH (TREE :A)
(HASH :A) (HASH :B) ⇒ HASH (MAP :A :B)
INTO
[CLASS]
INTO :A :B
INTO imples every element of :a can be represented by an element of :b. This conversion might not be injective (i.e., there may be elements in :a that don’t correspond to any in :b).
Methods:
INTO :: (:A → :B)
Instances
INTO :A :A
INTO U8 U16
INTO U8 I16
INTO U8 U32
INTO U8 I32
INTO U8 U64
INTO U8 I64
INTO U8 UFIX
INTO U8 IFIX
INTO U8 INTEGER
INTO I8 I16
INTO I8 I32
INTO I8 I64
INTO I8 IFIX
INTO I8 INTEGER
INTO U16 U32
INTO U16 I32
INTO U16 U64
INTO U16 I64
INTO U16 UFIX
INTO U16 IFIX
INTO U16 INTEGER
INTO I16 I32
INTO I16 I64
INTO I16 IFIX
INTO I16 INTEGER
INTO U32 U64
INTO U32 I64
INTO U32 UFIX
INTO U32 IFIX
INTO U32 INTEGER
INTO I32 I64
INTO I32 IFIX
INTO I32 INTEGER
INTO U64 INTEGER
INTO I64 INTEGER
INTO UFIX U64
INTO UFIX I64
INTO UFIX IFIX
INTO UFIX INTEGER
INTO IFIX I64
INTO IFIX INTEGER
INTO U8 SINGLE-FLOAT
INTO I8 SINGLE-FLOAT
INTO U16 SINGLE-FLOAT
INTO I16 SINGLE-FLOAT
INTO U8 DOUBLE-FLOAT
INTO I8 DOUBLE-FLOAT
INTO U16 DOUBLE-FLOAT
INTO I16 DOUBLE-FLOAT
INTO U32 DOUBLE-FLOAT
INTO I32 DOUBLE-FLOAT
COMPLEX :A ⇒ INTO :A (COMPLEX :A)
INTO DYADIC FRACTION
INTO INTEGER DYADIC
INTO STRING (LIST CHAR)
INTO (LIST CHAR) STRING
INTO INTEGER STRING
INTO SINGLE-FLOAT STRING
INTO DOUBLE-FLOAT STRING
INTO (TUPLE :A :B) (TUPLE :B :A)
INTO (RESULT :A :B) (OPTIONAL :B)
INTO (OPTIONAL :A) (RESULT UNIT :A)
INTO :A (CELL :A)
INTO (CELL :A) :A
RUNTIMEREPR :A ⇒ INTO (LIST :A) (VECTOR :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (LIST :A)
RUNTIMEREPR :A ⇒ INTO (SLICE :A) (VECTOR :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (SLICE :A)
INTO (MAPPAIR :A :B) (TUPLE :A :B)
INTO INTEGER BIG-FLOAT
INTO FRACTION BIG-FLOAT
INTO SINGLE-FLOAT BIG-FLOAT
INTO DOUBLE-FLOAT BIG-FLOAT
MONAD
[CLASS]
APPLICATIVE :A ⇒ MONAD :A
Types which are monads as defined in Haskell. See https://wiki.haskell.org/Monad for more information.
Methods:
>>= :: ((:A :B) → (:B → (:A :C)) → (:A :C))
MONOID
[CLASS]
Types with an associative binary operation and identity defined.
Methods:
MEMPTY :: :A
Instances
FUNCTOR
[CLASS]
FUNCTOR :A
Types which can map an inner type where the mapping adheres to the identity and composition laws.
Methods:
MAP :: ((:B → :C) → (:A :B) → (:A :C))
Instances
TRYINTO
[CLASS]
TRYINTO :A :B
TRY-INTO implies most elements of :a can be represented exactly by an element of :b, but sometimes not. If not, an error string is returned.
Methods:
Instances
TRYINTO SINGLE-FLOAT FRACTION
TRYINTO DOUBLE-FLOAT FRACTION
TRYINTO U8 I8
TRYINTO I8 U8
TRYINTO I8 U16
TRYINTO I8 U32
TRYINTO I8 U64
TRYINTO I8 UFIX
TRYINTO U16 U8
TRYINTO U16 I8
TRYINTO U16 I16
TRYINTO I16 U8
TRYINTO I16 I8
TRYINTO I16 U16
TRYINTO I16 U32
TRYINTO I16 U64
TRYINTO I16 UFIX
TRYINTO U32 U8
TRYINTO U32 I8
TRYINTO U32 U16
TRYINTO U32 I16
TRYINTO U32 I32
TRYINTO I32 U8
TRYINTO I32 I8
TRYINTO I32 U16
TRYINTO I32 I16
TRYINTO I32 U32
TRYINTO I32 U64
TRYINTO I32 UFIX
TRYINTO U64 U8
TRYINTO U64 I8
TRYINTO U64 U16
TRYINTO U64 I16
TRYINTO U64 U32
TRYINTO U64 I32
TRYINTO U64 I64
TRYINTO U64 UFIX
TRYINTO U64 IFIX
TRYINTO I64 U8
TRYINTO I64 I8
TRYINTO I64 U16
TRYINTO I64 I16
TRYINTO I64 U32
TRYINTO I64 I32
TRYINTO I64 U64
TRYINTO I64 UFIX
TRYINTO I64 IFIX
TRYINTO UFIX U8
TRYINTO UFIX I8
TRYINTO UFIX U16
TRYINTO UFIX I16
TRYINTO UFIX U32
TRYINTO UFIX I32
TRYINTO IFIX U8
TRYINTO IFIX I8
TRYINTO IFIX U16
TRYINTO IFIX I16
TRYINTO IFIX U32
TRYINTO IFIX I32
TRYINTO IFIX U64
TRYINTO IFIX UFIX
TRYINTO INTEGER U8
TRYINTO INTEGER I8
TRYINTO INTEGER U16
TRYINTO INTEGER I16
TRYINTO INTEGER U32
TRYINTO INTEGER I32
TRYINTO INTEGER U64
TRYINTO INTEGER I64
TRYINTO INTEGER UFIX
TRYINTO INTEGER IFIX
TRYINTO INTEGER SINGLE-FLOAT
TRYINTO INTEGER DOUBLE-FLOAT
TRYINTO STRING INTEGER
FOLDABLE
[CLASS]
FOLDABLE :A
Types which can be folded into a single element.
fold
is a left tail recursive fold
foldr
is a right non tail recursive fold
Methods:
FOLD :: ((:B → :C → :B) → :B → (:A :C) → :B)
FOLDR :: ((:D → :E → :E) → :E → (:A :D) → :E)
BIFUNCTOR
[CLASS]
BIFUNCTOR :A
Types which take two type arguments and are functors on both.
Methods:
BIMAP :: ((:B → :C) → (:D → :E) → ((:A :B) :D) → ((:A :C) :E))
MONADFAIL
[CLASS]
Methods:
FAIL :: (STRING → (:A :B))
SEMIGROUP
[CLASS]
SEMIGROUP :A
Types with an associative binary operation defined.
Methods:
<> :: (:A → :A → :A)
Instances
ADDRESSABLE
[CLASS]
ADDRESSABLE :A
Types for which object identity is meaningful.
eq?
should correspond exactly to the Common Lisp function eq
, testing object identity (aka pointer
equality).
The compiler will auto-generate instances of Addressable
for types which specify repr :enum
or repr :lisp
.
Types with repr :native
may manually implement Addressable
, but programmers are encouraged to check the
Common Lisp Hyperspec to determine what
guarantees, if any, are imposed on the behavior of eq
. Types represented by cl:character
or
cl:number
(or sub- or supertypes thereof) should not implement Addressable
, as those objects may be
implicitly copied.
No other types may implement Addressable
. Defining an Addressable
instance manually for a type which does
not specify repr :native
will error. If you need an Addressable
instance for a non-repr :native
type,
specify repr :lisp
.
Methods:
EQ? :: (:A → :A → BOOLEAN)
Instances
ADDRESSABLE UNIT
ADDRESSABLE ORD
ADDRESSABLE (LIST :A)
ADDRESSABLE STRING
ADDRESSABLE (CELL :A)
ADDRESSABLE (VECTOR :A)
ADDRESSABLE (SLICE :A)
ADDRESSABLE (HASHTABLE :A :B)
ADDRESSABLE COLOR
ALTERNATIVE
[CLASS]
APPLICATIVE :A ⇒ ALTERNATIVE :A
Types which are monoids on applicative functors.
Methods:
ALT :: ((:A :B) → (:A :B) → (:A :B))
EMPTY :: (:A :C)
Instances
APPLICATIVE
[CLASS]
FUNCTOR :A ⇒ APPLICATIVE :A
Types which are a functor which can embed pure expressions and sequence operations.
Methods:
PURE :: (:B → (:A :B))
LIFTA2 :: ((:C → :D → :E) → (:A :C) → (:A :D) → (:A :E))
Instances
TRAVERSABLE
[CLASS]
TRAVERSABLE :A
Methods:
TRAVERSE :: APPLICATIVE :B ⇒ ((:C → (:B :D)) → (:A :C) → (:B (:A :D)))
Instances
UNWRAPPABLE
[CLASS]
UNWRAPPABLE :A
Containers which can be unwrapped to get access to their contents.
(unwrap-or-else SUCCEED FAIL CONTAINER) should invoke the SUCCEED continuation on the unwrapped contents of CONTAINER when successful, or invoke the FAIL continuation with no arguments (i.e. with Unit as an argument) when unable to unwrap a value.
The SUCCEED continuation will often, but not always, be the identity function. as-optional
passes Some to
construct an Optional.
Typical fail
continuations are:
- Return a default value, or
- Signal an error.
Methods:
UNWRAP-OR-ELSE :: ((:B → :C) → (UNIT → :C) → (:A :B) → :C)
Instances
Values
(< X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → BOOLEAN)
Is X less than Y?
(> X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → BOOLEAN)
Is X greater than Y?
(<= X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → BOOLEAN)
Is X less than or equal to Y?
(>= X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → BOOLEAN)
Is X greater than or equal to Y?
(>> A B)
FUNCTION
∀ :A :B :C. MONAD :A ⇒ ((:A :B) → (:A :C) → (:A :C))
(MAX X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → :A)
Returns the greater element of X and Y.
(MIN X Y)
FUNCTION
∀ :A. ORD :A ⇒ (:A → :A → :A)
Returns the lesser element of X and Y.
(ERROR STR)
FUNCTION
∀ :A. (STRING → :A)
Signal an error by calling CL:ERROR
.
(EXPECT REASON CONTAINER)
FUNCTION
∀ :A :B. UNWRAPPABLE :A ⇒ (STRING → (:A :B) → :B)
Unwrap CONTAINER, signaling an error with the description REASON on failure.
(UNWRAP CONTAINER)
FUNCTION
∀ :A :B. UNWRAPPABLE :A ⇒ ((:A :B) → :B)
Unwrap CONTAINER, signaling an error on failure.
(MAP-FST F B)
FUNCTION
∀ :A :B :C :D. BIFUNCTOR :C ⇒ ((:A → :B) → (:C :A :D) → (:C :B :D))
Map over the first argument of a Bifunctor.
(MAP-SND F B)
FUNCTION
∀ :A :B :C :D. BIFUNCTOR :C ⇒ ((:A → :B) → (:C :D :A) → (:C :D :B))
Map over the second argument of a Bifunctor.
MCONCAT
[FUNCTION]
∀ :A :B. (FOLDABLE :A) (MONOID :B) ⇒ ((:A :B) → :B)
Fold a container of monoids into a single element.
SEQUENCE
[FUNCTION]
∀ :A :B :C. (TRAVERSABLE :A) (APPLICATIVE :B) ⇒ ((:A (:B :C)) → (:B (:A :C)))
(AS-OPTIONAL CONTAINER)
FUNCTION
∀ :A :B. UNWRAPPABLE :A ⇒ ((:A :B) → (OPTIONAL :B))
Convert any Unwrappable container into an Optional, constructing Some on a successful unwrap and None on a failed unwrap.
(WITH-DEFAULT DEFAULT CONTAINER)
FUNCTION
∀ :A :B. UNWRAPPABLE :B ⇒ (:A → (:B :A) → :A)
Unwrap CONTAINER, returning DEFAULT on failure.
(COMBINE-HASHES LEFT RIGHT)
FUNCTION
Package coalton-library/types
types.lisp
Types
PROXY :A
[TYPE]
PROXY
Proxy holds no data, but has a phantom type parameter.
Instances
RUNTIMEREPR (PROXY :A)
LISPTYPE
[TYPE]
The runtime representation of a Coalton type as a lisp type.
Instances
Classes
RUNTIMEREPR
[CLASS]
RUNTIMEREPR :A
Types which have a runtime LispType representation.
runtime-repr
corresponds to the type emitted by the Coalton compiler for the type parameter to the given Proxy.
The compiler will auto-generate instances of RuntimeRepr
for all defined types.
Methods:
Instances
RUNTIMEREPR BOOLEAN
RUNTIMEREPR CHAR
RUNTIMEREPR INTEGER
RUNTIMEREPR SINGLE-FLOAT
RUNTIMEREPR DOUBLE-FLOAT
RUNTIMEREPR STRING
RUNTIMEREPR FRACTION
RUNTIMEREPR (:A → :B)
RUNTIMEREPR (LIST :A)
RUNTIMEREPR LISPTYPE
RUNTIMEREPR (PROXY :A)
RUNTIMEREPR UFIX
RUNTIMEREPR IFIX
RUNTIMEREPR I64
RUNTIMEREPR I32
RUNTIMEREPR I16
RUNTIMEREPR I8
RUNTIMEREPR U64
RUNTIMEREPR U32
RUNTIMEREPR U16
RUNTIMEREPR U8
RUNTIMEREPR VOID
RUNTIMEREPR UNIT
RUNTIMEREPR ORD
RUNTIMEREPR (RESULT :A :B)
RUNTIMEREPR (OPTIONAL :A)
RUNTIMEREPR (TUPLE :A :B)
RUNTIMEREPR (QUANTIZATION :A)
RUNTIMEREPR (COMPLEX :A)
RUNTIMEREPR DYADIC
RUNTIMEREPR (TUPLE5 :A :B :C :D :E)
RUNTIMEREPR (TUPLE4 :A :B :C :D)
RUNTIMEREPR (TUPLE3 :A :B :C)
RUNTIMEREPR (CELL :A)
RUNTIMEREPR (VECTOR :A)
RUNTIMEREPR (SLICE :A)
RUNTIMEREPR (HASHTABLE :A :B)
RUNTIMEREPR (ST :A :B)
RUNTIMEREPR (ITERATOR :A)
RUNTIMEREPR COLOR
RUNTIMEREPR (TREE :A)
RUNTIMEREPR (ITERATORSTACKNODE :A)
RUNTIMEREPR (MAPPAIR :A :B)
RUNTIMEREPR (MAP :A :B)
RUNTIMEREPR BIG-FLOAT
RUNTIMEREPR ROUNDINGMODE
Values
(PROXY-OF _)
FUNCTION
∀ :A. (:A → (PROXY :A))
Returns a Proxy containing the type of the parameter.
(AS-PROXY-OF X _)
FUNCTION
∀ :A. (:A → (PROXY :A) → :A)
Returns the parameter, forcing the proxy to have the same type as the parameter.
(RUNTIME-REPR-OF X)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ (:A → LISPTYPE)
Returns the runtime representation of the type of the given value.
Package coalton-library/builtin
builtin.lisp
Values
NOT
[FUNCTION]
Synonym for BOOLEAN-NOT.
XOR
[FUNCTION]
Synonym for BOOLEAN-XOR.
(UNDEFINED X)
FUNCTION
∀ :A :B. (:A → :B)
A function which can be used in place of any value, throwing an error at runtime.
(BOOLEAN-OR X Y)
FUNCTION
Is X or Y True? Note that this is a function which means both X and Y will be evaluated. Use the OR macro for short-circuiting behavior.
(BOOLEAN-AND X Y)
FUNCTION
Are X and Y True? Note that this is a function which means both X and Y will be evaluated. Use the AND macro for short-circuiting behavior.
(BOOLEAN-NOT X)
FUNCTION
Is X False?
(BOOLEAN-XOR X Y)
FUNCTION
Are X or Y True, but not both?
Package coalton-library/functions
functions.lisp
Values
(/= A B)
FUNCTION
∀ :A. EQ :A ⇒ (:A → :A → BOOLEAN)
Is A not equal to B?
(ID X)
FUNCTION
∀ :A. (:A → :A)
A function that always returns its argument.
(FIX F N)
FUNCTION
∀ :A :B. (((:A → :B) → :A → :B) → :A → :B)
Compute the fixed point of a unary function. This is equivalent to the Y-combinator of the lambda calculus. This combinator allows recursion without specific assignment of names. For example, the factorial function can be written
(define fact
(fix
(fn (f n)
(if (== n 0)
1
(* n (f (- n 1)))))))
(ASUM XS)
FUNCTION
∀ :A :B :C. (ALTERNATIVE :B) (FOLDABLE :A) ⇒ ((:A (:B :C)) → (:B :C))
Fold over a list using alt
(FLIP F X Y)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → :B → :A → :C)
Returns a function that takes its arguments in reverse order.
(MSUM XS)
FUNCTION
∀ :A :B. (MONOID :B) (FOLDABLE :A) ⇒ ((:A :B) → :B)
Fold over a list using <>
(CONST A B)
FUNCTION
∀ :A :B. (:A → :B → :A)
A function that always returns its first argument.
(TRACE STR)
FUNCTION
Print a line to *STANDARD-OUTPUT*
(REDUCE F Y XS)
FUNCTION
∀ :A :B :C. FOLDABLE :C ⇒ ((:A → :B → :B) → :B → (:C :A) → :B)
The same as fold
but with the argument order swapped to match cl:reduce
(COMPOSE F G)
FUNCTION
∀ :A :B :C. ((:A → :B) → (:C → :A) → :C → :B)
Produces a function equivalent to applying G then F in succession.
(CONJOIN F G X)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (:A → BOOLEAN) → :A → BOOLEAN)
Compute the conjunction of two unary Boolean functions.
(DISJOIN F G X)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (:A → BOOLEAN) → :A → BOOLEAN)
Compute the disjunction of two unary Boolean functions.
(UNCURRY FUNC TPL)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (TUPLE :A :B) → :C)
(COMPLEMENT F X)
FUNCTION
∀ :A. ((:A → BOOLEAN) → :A → BOOLEAN)
Compute the complement of a unary Boolean function.
(TRACEOBJECT STR ITEM)
FUNCTION
Print a line to *STANDARD-OUTPUT*
in the form “{STR}: {ITEM}”
Package coalton-library/math/arith
math/arith.lisp
Classes
DIVIDABLE
[CLASS]
DIVIDABLE :A :B
The representation of a type such that division within that type possibly results in another type. For instance,
(Dividable Integer Fraction)
establishes that division of two Integer
s can result in a Fraction
, whereas
(Dividable Single-Float Single-Float)
establishes that division of two Single-Float
s can result in a Single-Float
.
Note that Dividable
does not establish a default result type; you must constrain the result type yourself.
The function general/ is partial, and will error produce a run-time error if the divisor is zero.
Methods:
GENERAL/ :: (:A → :A → :B)
Instances
TRANSFINITE
[CLASS]
TRANSFINITE :A
Numberic type with a value for (positive) ‘infinity’ and/or ‘NaN’
Methods:
RECIPROCABLE
[CLASS]
NUM :A ⇒ RECIPROCABLE :A
Any number with a multiplicative inverse (reciprocal) where:
1 = (* (reciprocal x) x) = (* x (reciprocal x))
(/ x y) = (* x (reciprocal y))
If no reciprocal exists for an element, produce a run-time error (e.g. zero).
Methods:
/ :: (:A → :A → :A)
RECIPROCAL :: (:A → :A)
Instances
Values
(1+ NUM)
FUNCTION
∀ :A. NUM :A ⇒ (:A → :A)
Increment num
.
(1- NUM)
FUNCTION
∀ :A. NUM :A ⇒ (:A → :A)
Decrement num
.
(ABS X)
FUNCTION
∀ :A. (ORD :A) (NUM :A) ⇒ (:A → :A)
Absolute value of x
.
(ASH X N)
FUNCTION
Compute the “arithmetic shift” of X by N.
(SIGN X)
FUNCTION
∀ :A :B. (ORD :A) (NUM :A) (NUM :B) ⇒ (:A → :B)
The sign of x
, where (sign 0) = 1
.
(NEGATE X)
FUNCTION
∀ :A. NUM :A ⇒ (:A → :A)
The negation, or additive inverse, of x
.
(FINITE? X)
FUNCTION
∀ :A. TRANSFINITE :A ⇒ (:A → BOOLEAN)
Neither infinite or NaN.
(NONZERO? X)
FUNCTION
Is x
not zero?
(NEGATIVE? X)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → BOOLEAN)
Is x
negative?
(POSITIVE? X)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → BOOLEAN)
Is x
positive?
(NONNEGATIVE? X)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → BOOLEAN)
Is x
not negative?
(NONPOSITIVE? X)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → BOOLEAN)
Is x
not positive?
NEGATIVE-INFINITY
[VALUE]
∀ :A. (TRANSFINITE :A) (NUM :A) ⇒ :A
Package coalton-library/math/bounded
math/bounded.lisp
Classes
BOUNDED
[CLASS]
BOUNDED :A
Types which have a maximum and minumum bound.
Methods:
MINBOUND :: :A
MAXBOUND :: :A
Instances
Package coalton-library/math/fraction
math/fraction.lisp
Values
(NUMERATOR Q)
FUNCTION
The numerator of a fraction.
(MKFRACTION A B)
FUNCTION
(INTEGER → INTEGER → FRACTION)
(DENOMINATOR Q)
FUNCTION
The denominator of a fraction.
Package coalton-library/math/integral
math/integral.lisp
Classes
INTEGRAL
[CLASS]
(REMAINDER :A) (ORD :A) ⇒ INTEGRAL :A
Integral is a number that is either even or odd where div
and quot
are floored and truncated division, respectively.
Methods:
TOINTEGER :: (:A → INTEGER)
Instances
REMAINDER
[CLASS]
Remainder is typically an integral domain satisfying:
a = (+ (* b (quot a b)) (rem a b))
a = (+ (* b (div a b)) (mod a b))
Methods:
QUOT :: (:A → :A → :A)
REM :: (:A → :A → :A)
QUOTREM :: (:A → :A → (TUPLE :A :A))
DIV :: (:A → :A → :A)
MOD :: (:A → :A → :A)
DIVMOD :: (:A → :A → (TUPLE :A :A))
Instances
Values
(^ BASE POWER)
FUNCTION
∀ :A :B. (NUM :A) (INTEGRAL :B) ⇒ (:A → :B → :A)
Exponentiate BASE to a non-negative POWER.
(^^ BASE POWER)
FUNCTION
∀ :A :B. (RECIPROCABLE :A) (INTEGRAL :B) ⇒ (:A → :B → :A)
Exponentiate BASE to a signed POWER.
(GCD A B)
FUNCTION
∀ :A. (REMAINDER :A) (ORD :A) ⇒ (:A → :A → :A)
The greatest common divisor of A and B.
(LCM A B)
FUNCTION
∀ :A. (REMAINDER :A) (ORD :A) ⇒ (:A → :A → :A)
The least common multiple of A and B.
(LSH X N)
FUNCTION
∀ :A :B. (INTEGRAL :B) (BITS :A) ⇒ (:A → :B → :A)
Left shift X by N
(RSH X N)
FUNCTION
∀ :A :B. (INTEGRAL :B) (BITS :A) ⇒ (:A → :B → :A)
Right shift X by N
(ILOG B X)
FUNCTION
∀ :A. INTEGRAL :A ⇒ (:A → :A → :A)
The floor of the logarithm with base B > 1 of X >= 1.
(ODD? N)
FUNCTION
∀ :A. INTEGRAL :A ⇒ (:A → BOOLEAN)
Is N odd?
(EVEN? N)
FUNCTION
∀ :A. INTEGRAL :A ⇒ (:A → BOOLEAN)
Is N even?
(ISQRT X)
FUNCTION
∀ :A. INTEGRAL :A ⇒ (:A → :A)
The floor of the square root of N > 0.
(INTEGRAL->NUM N)
FUNCTION
∀ :A :B. (INTEGRAL :A) (NUM :B) ⇒ (:A → :B)
Converts any Integral N into any Num.
Package coalton-library/math/real
math/real.lisp
Types
QUANTIZATION :A
[TYPE]
Represents an integer quantization of :a
.
The fields are defined as follows:
- A value of type
:a
. - The greatest integer less than or equal to a particular value.
- The remainder of this as a value of type
:a
. - The least integer greater than or equal to a particular value.
- The remainder of this as a value of type
:a
.
Instances
RUNTIMEREPR (QUANTIZATION :A)
Classes
REAL
[CLASS]
(QUANTIZABLE :A) (NUM :A) ⇒ REAL :A
A real number that can be approximated with abs(real-approx x - x) < 2^-n.
Methods:
Instances
RATIONAL
[CLASS]
(REAL :A) (ORD :A) ⇒ RATIONAL :A
Any number that can be exactly represented by a fraction, or is not finite.
If a rational can be converted from a fraction it must satisfy:
(into (to-fraction x)) = x
(into (best-approx x)) = x
Furthermore, best-approx
returns the simplest fraction, and both functions may be partial.
Methods:
Instances
QUANTIZABLE
[CLASS]
QUANTIZABLE :A
The representation of a type that allows for rounding operations
max x such that (floor x) <= x
min x such that (ceiling x) <= x
And
(proper x) = (Tuple (truncate x) (- x (truncate x)))
where
(truncate x) = (* (sign x) (floor (abs x))
Methods:
Instances
Values
(ROUND X)
FUNCTION
∀ :A. (QUANTIZABLE :A) (NUM :A) ⇒ (:A → INTEGER)
Return the nearest integer to X, with ties breaking towards even numbers.
(SAFE/ X Y)
FUNCTION
∀ :A :B. (NUM :A) (DIVIDABLE :A :B) ⇒ (:A → :A → (OPTIONAL :B))
Safely divide X by Y, returning None if Y is zero.
(EXACT/ A B)
FUNCTION
(INTEGER → INTEGER → FRACTION)
Exactly divide two integers and produce a fraction.
(FLOOR/ A B)
FUNCTION
Divide two integers and compute the floor of the quotient.
(ROUND/ A B)
FUNCTION
Divide two integers and round the quotient.
(CEILING/ A B)
FUNCTION
Divide two integers and compute the ceiling of the quotient.
(INEXACT/ A B)
FUNCTION
(INTEGER → INTEGER → DOUBLE-FLOAT)
Compute the quotient of integers as a double-precision float.
Note: This does not divide double-float arguments.
(QUANTIZE X)
FUNCTION
∀ :A. REAL :A ⇒ (:A → (QUANTIZATION :A))
Given X, (QUANTIZE X) will return the least integer greater or equal to X, and the greatest integer less than or equal to X, along with their respective remainders expressed as values of type of X.
(TRUNCATE X)
FUNCTION
∀ :A. QUANTIZABLE :A ⇒ (:A → INTEGER)
Returns the integer closest/equal to x
that is within 0
and x
.
(ROUND-HALF-UP X)
FUNCTION
∀ :A. (QUANTIZABLE :A) (NUM :A) ⇒ (:A → INTEGER)
Return the nearest integer to X, with ties breaking toward positive infinity.
(ROUND-HALF-DOWN X)
FUNCTION
∀ :A. (QUANTIZABLE :A) (NUM :A) ⇒ (:A → INTEGER)
Return the nearest integer to X, with ties breaking toward positive infinity.
Package coalton-library/math/complex
math/complex.lisp
Types
COMPLEX :A
[TYPE]
Complex number that may either have a native or constructed representation.
Instances
RUNTIMEREPR (COMPLEX :A)
COMPLEX :A ⇒ EQ (COMPLEX :A)
COMPLEX :A ⇒ NUM (COMPLEX :A)
COMPLEX :A ⇒ INTO :A (COMPLEX :A)
(COMPLEX :A) (RECIPROCABLE :A) ⇒ RECIPROCABLE (COMPLEX :A)
COMPLEX :A ⇒ COMPLEX (COMPLEX :A)
ELEMENTARY :A ⇒ POLAR (COMPLEX :A)
ELEMENTARY :A ⇒ RADICAL (COMPLEX :A)
ELEMENTARY :A ⇒ ELEMENTARY (COMPLEX :A)
ELEMENTARY :A ⇒ EXPONENTIABLE (COMPLEX :A)
ELEMENTARY :A ⇒ TRIGONOMETRIC (COMPLEX :A)
Classes
COMPLEX
[CLASS]
Methods:
COMPLEX :: (:A → :A → (COMPLEX :A))
REAL-PART :: ((COMPLEX :A) → :A)
IMAG-PART :: ((COMPLEX :A) → :A)
Instances
Values
II
[VALUE]
∀ :A. COMPLEX :A ⇒ (COMPLEX :A)
The complex unit i. (The double ii represents a blackboard-bold i.)
(CONJUGATE N)
FUNCTION
∀ :A. COMPLEX :A ⇒ ((COMPLEX :A) → (COMPLEX :A))
The complex conjugate.
(SQUARE-MAGNITUDE A)
FUNCTION
∀ :A. COMPLEX :A ⇒ ((COMPLEX :A) → :A)
The length of a complex number.
Package coalton-library/math/elementary
math/elementary.lisp
Classes
POLAR
[CLASS]
(COMPLEX :A) (NUM :A) ⇒ POLAR :A
For a complex number z = (complex x y)
, the following identities hold:
z = (* (magnitude z) (exp (* ii (phase z))))
(polar z) = (Tuple (magnitude z) (phase z))
(phase z) = (atan2 y x)
Methods:
Instances
POLAR SINGLE-FLOAT
POLAR DOUBLE-FLOAT
ELEMENTARY :A ⇒ POLAR (COMPLEX :A)
POLAR BIG-FLOAT
RADICAL
[CLASS]
RADICAL :A
Obeys:
(^ (sqrt x) 2) = x = (^^ (nth-root n x) n)
Methods:
NTH-ROOT :: (INTEGER → :A → :A)
SQRT :: (:A → :A)
Instances
ELEMENTARY
[CLASS]
(RECIPROCABLE :A) (POLAR :A) (TRIGONOMETRIC :A) (EXPONENTIABLE :A) (RADICAL :A) ⇒ ELEMENTARY :A
Numbers that can be can be passed to elementary functions.
Methods:
EE :: :A
PI :: :A
Instances
EXPONENTIABLE
[CLASS]
Exponential maps obeying:
(* (exp x) (exp y)) = (exp (+ x y))
(exp (ln x)) = x = (ln (exp x))
(log b x) = (/ (ln x) (ln b))
(pow x y) = (exp (* y (ln x)))
Methods:
EXP :: (:A → :A)
POW :: (:A → :A → :A)
LN :: (:A → :A)
LOG :: (:A → :A → :A)
Instances
TRIGONOMETRIC
[CLASS]
Standard circular functions and their inverses.
Methods:
SIN :: (:A → :A)
COS :: (:A → :A)
TAN :: (:A → :A)
ASIN :: (:A → :A)
ACOS :: (:A → :A)
ATAN :: (:A → :A)
Instances
Values
(CIS Z)
FUNCTION
∀ :A. (TRIGONOMETRIC :A) (COMPLEX :A) ⇒ (:A → (COMPLEX :A))
A point on the complex unit circle:
(cis z) := (exp (complex 0 z))
= (complex (cos z) (sin z))
(COSH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(SINH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(TANH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(ACOSH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(ASINH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(ATAN2 Y X)
FUNCTION
∀ :A. (ORD :A) (ELEMENTARY :A) ⇒ (:A → :A → :A)
Computes the two-argument arctangent of y and x, which is roughly the same as (atan (/ y x)) when defined and accounting for the quadrant of the (x,y).
(ATANH X)
FUNCTION
∀ :A. ELEMENTARY :A ⇒ (:A → :A)
(SINCOS X)
FUNCTION
∀ :A. TRIGONOMETRIC :A ⇒ (:A → (TUPLE :A :A))
Computes the sine and cosine of X.
(MAGNITUDE Z)
FUNCTION
∀ :A. (RADICAL :A) (COMPLEX :A) ⇒ ((COMPLEX :A) → :A)
For z = x + yi
,
(magnitude z) = (sqrt (+ (^ x 2) (^ y 2)))
Package coalton-library/bits
bits.lisp
Classes
BITS
[CLASS]
Operations on the bits of twos-complement integers
Methods:
AND :: (:A → :A → :A)
OR :: (:A → :A → :A)
XOR :: (:A → :A → :A)
NOT :: (:A → :A)
SHIFT :: (INTEGER → :A → :A)
Instances
Package coalton-library/char
char.lisp
Values
(ALPHA? C)
FUNCTION
Is C an alphabetic character?
(DIGIT? C)
FUNCTION
Is C a digit character?
(UPCASE C)
FUNCTION
Returns the upcased version of C, returning C when there is none.
(DOWNCASE C)
FUNCTION
Returns the downcased version of C, returning C when there is none.
(CHAR-CODE CHAR)
FUNCTION
Convert a character to its ASCII representation.
(CODE-CHAR CODE)
FUNCTION
Convert a number to its ASCII character, returning None on failure.
(LOWERCASE? C)
FUNCTION
Is C a lowercase character?
(UPPERCASE? C)
FUNCTION
Is C an uppercase character?
(ASCII-ALPHA? C)
FUNCTION
Is C an ASCII alphabetic character?
(ASCII-DIGIT? C)
FUNCTION
Is C an ASCII digit character?
(ASCII-LOWERCASE? C)
FUNCTION
Is C an ASCII lowercase character?
(ASCII-UPPERCASE? C)
FUNCTION
Is C an ASCII uppercase character?
(ASCII-ALPHANUMERIC? C)
FUNCTION
Is C an ASCII alphanumeric character?
Package coalton-library/string
string.lisp
Values
(REF STR IDX)
FUNCTION
(STRING → UFIX → (OPTIONAL CHAR))
Return the IDXth character of STR.
(CONCAT STR1 STR2)
FUNCTION
Concatenate STR1 and STR2 together, returning a new string.
(LENGTH STR)
FUNCTION
The length of a string STR.
(REVERSE S)
FUNCTION
Reverse a string.
(PARSE-INT STR)
FUNCTION
Parse the integer in string STR.
(SUBSTRING STR START END)
FUNCTION
(STRING → UFIX → UFIX → STRING)
Compute a substring of a string bounded by given indices.
(SUBSTRING? SMALL BIG)
FUNCTION
Return true if the first argument appears as a substring within the second argument.
(STRIP-PREFIX PREFIX STR)
FUNCTION
(STRING → STRING → (OPTIONAL STRING))
Returns a string without a give prefix, or None if the string does not have that suffix.
(STRIP-SUFFIX SUFFIX STR)
FUNCTION
(STRING → STRING → (OPTIONAL STRING))
Returns a string without a give suffix, or None if the string does not have that suffix.
(REF-UNCHECKED STR IDX)
FUNCTION
Return the IDXth character of STR. This function is partial.
(SUBSTRING-INDEX SMALL BIG)
FUNCTION
(STRING → STRING → (OPTIONAL UFIX))
If the first argument appears as a substring within the second argument, return the starting index into the second argument.
Package coalton-library/tuple
tuple.lisp
Types
TUPLE3 :A :B :C
[TYPE]
(TUPLE3 :A :B :C)
Instances
TUPLE4 :A :B :C :D
[TYPE]
(TUPLE4 :A :B :C :D)
Instances
TUPLE5 :A :B :C :D :E
[TYPE]
(TUPLE5 :A :B :C :D :E)
Instances
Values
(FST T)
FUNCTION
∀ :A :B. ((TUPLE :A :B) → :A)
Get the first element of a tuple.
(SND T)
FUNCTION
∀ :A :B. ((TUPLE :A :B) → :B)
Get the second element of a tuple.
Package coalton-library/optional
optional.lisp
Values
(NONE? X)
FUNCTION
∀ :A. ((OPTIONAL :A) → BOOLEAN)
Is X None?
(SOME? X)
FUNCTION
∀ :A. ((OPTIONAL :A) → BOOLEAN)
Is X Some?
(FROM-SOME STR OPT)
FUNCTION
∀ :A. (STRING → (OPTIONAL :A) → :A)
Get the value of OPT, erroring with the provided string if it is None.
Package coalton-library/list
list.lisp
Values
(ALL F XS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → BOOLEAN)
Returns TRUE if every element in XS matches F.
(ANY F L)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → BOOLEAN)
Returns TRUE if at least one element in XS matches F.
(CAR X)
FUNCTION
∀ :A. ((LIST :A) → :A)
Return the traditional car of a list. This function is partial
(CDR XS)
FUNCTION
Return the traditional cdr of a list.
(NTH N L)
FUNCTION
Like INDEX, but errors if the index is not found.
(SUM XS)
FUNCTION
∀ :A. NUM :A ⇒ ((LIST :A) → :A)
Returns the sum of XS
(ZIP XS YS)
FUNCTION
∀ :A :B. ((LIST :A) → (LIST :B) → (LIST (TUPLE :A :B)))
Builds a list of tuples with the elements of XS and YS.
(DROP N XS)
FUNCTION
∀ :A. (UFIX → (LIST :A) → (LIST :A))
Returns a list with the first N elements removed.
(FIND F XS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → (OPTIONAL :A))
Returns the first element in a list matching the predicate function F.
(HEAD L)
FUNCTION
∀ :A. ((LIST :A) → (OPTIONAL :A))
Returns the first element of a list.
(INIT L)
FUNCTION
Returns every element except the last in a list.
(LAST L)
FUNCTION
∀ :A. ((LIST :A) → (OPTIONAL :A))
Returns the last element of a list.
(SORT XS)
FUNCTION
∀ :A. ORD :A ⇒ ((LIST :A) → (LIST :A))
Performs a sort of XS.
(TAIL L)
FUNCTION
∀ :A. ((LIST :A) → (OPTIONAL (LIST :A)))
Returns every element except the first in a list.
(TAKE N XS)
FUNCTION
∀ :A. (UFIX → (LIST :A) → (LIST :A))
Returns the first N elements of a list.
(COMBS L)
FUNCTION
∀ :A. ((LIST :A) → (LIST (LIST :A)))
Compute a list of all combinations of elements of L. This function is sometimes goes by the name “power set” or “subsets”.
The ordering of elements of L is preserved in the ordering of elements in each list produced by (COMBS L)
.
(INDEX I XS)
FUNCTION
∀ :A. (UFIX → (LIST :A) → (OPTIONAL :A))
Returns the Ith element of a list.
(NULL? XS)
FUNCTION
Returns TRUE if XS is an empty list.
(PERMS L)
FUNCTION
∀ :A. ((LIST :A) → (LIST (LIST :A)))
Produce all permutations of the list L.
(RANGE START END)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → :A → (LIST :A))
Returns a list containing the numbers from START to END inclusive, counting by 1.
```
> COALTON-USER> (coalton (range 1 5))
(1 2 3 4 5)
> COALTON-USER> (coalton (range 5 2))
(5 4 3 2)
```
(SPLIT C STR)
FUNCTION
(CHAR → STRING → (LIST STRING))
(UNION XS YS)
FUNCTION
∀ :A. EQ :A ⇒ ((LIST :A) → (LIST :A) → (LIST :A))
Returns a new list with the elements from both XS and YS and without duplicates.
(APPEND XS YS)
FUNCTION
∀ :A. ((LIST :A) → (LIST :A) → (LIST :A))
Appends two lists together and returns a new list.
(CONCAT XS)
FUNCTION
∀ :A. ((LIST (LIST :A)) → (LIST :A))
Appends a list of lists together into a single new list.
(DELETE X YS)
FUNCTION
∀ :A. EQ :A ⇒ (:A → (LIST :A) → (LIST :A))
Return a new list with the first element equal to X removed.
(FILTER F XS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → (LIST :A))
Returns a new list containing every element of XS that matches the predicate function F in the same order.
(INSERT E LS)
FUNCTION
∀ :A. ORD :A ⇒ (:A → (LIST :A) → (LIST :A))
Inserts an element into a list at the first place it is less than or equal to the next element.
(LENGTH L)
FUNCTION
Returns the length of a list.
(LOOKUP E XS)
FUNCTION
∀ :A :B. EQ :A ⇒ (:A → (LIST (TUPLE :A :B)) → (OPTIONAL :B))
Returns the value of the first (key, value) tuple in XS where the key matches E.
(MEMBER E XS)
FUNCTION
∀ :A. EQ :A ⇒ (:A → (LIST :A) → BOOLEAN)
Returns true if any element of XS is equal to E.
(REPEAT N X)
FUNCTION
Returns a list with the same value repeated multiple times.
(SORTBY CMP XS)
FUNCTION
∀ :A. ((:A → :A → ORD) → (LIST :A) → (LIST :A))
Generic version of sort
(COMBSOF N L)
FUNCTION
∀ :A. (UFIX → (LIST :A) → (LIST (LIST :A)))
Produce a list of size-N subsets of L.
The ordering of elements of L is preserved in the ordering of elements in each list produced by (COMBSOF N L)
.
This function is equivalent to all size-N elements of (COMBS L)
.
(COUNTBY F THINGS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → UFIX)
Count the number of items in THINGS that satisfy the predicate F.
(MAXIMUM L)
FUNCTION
∀ :A. ORD :A ⇒ ((LIST :A) → (OPTIONAL :A))
Returns a greatest element of a list, or None.
(MINIMUM L)
FUNCTION
∀ :A. ORD :A ⇒ ((LIST :A) → (OPTIONAL :A))
Returns a least element of a list, or None.
(PRODUCT XS)
FUNCTION
∀ :A. NUM :A ⇒ ((LIST :A) → :A)
Returns the product of XS
(REVERSE XS)
FUNCTION
Returns a new list containing the same elements in reverse order.
(ZIPWITH F XS YS)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (LIST :A) → (LIST :B) → (LIST :C))
Builds a new list by calling F with elements of XS and YS.
(INSERTBY CMP X YS)
FUNCTION
∀ :A. ((:A → :A → ORD) → :A → (LIST :A) → (LIST :A))
Generic version of insert
(ZIPWITH3 F XS YS ZS)
FUNCTION
∀ :A :B :C :D. ((:A → :B → :C → :D) → (LIST :A) → (LIST :B) → (LIST :C) → (LIST :D))
Build a new list by calling F with elements of XS, YS and ZS
(ZIPWITH4 F AS BS CS DS)
FUNCTION
∀ :A :B :C :D :E. ((:A → :B → :C → :D → :E) → (LIST :A) → (LIST :B) → (LIST :C) → (LIST :D) → (LIST :E))
Build a new list by calling F with elements of AS, BS, CS and DS
(ZIPWITH5 F AS BS CS DS ES)
FUNCTION
∀ :A :B :C :D :E :F. ((:A → :B → :C → :D → :E → :F) → (LIST :A) → (LIST :B) → (LIST :C) → (LIST :D) → (LIST :E) → (LIST :F))
Build a new list by calling F with elements of AS, BS, CS, DS and ES
(CONCATMAP F XS)
FUNCTION
∀ :A :B. ((:A → (LIST :B)) → (LIST :A) → (LIST :B))
Apply F to each element in XS and concatenate the results.
(ELEMINDEX X XS)
FUNCTION
∀ :A. EQ :A ⇒ (:A → (LIST :A) → (OPTIONAL UFIX))
(FINDINDEX F XS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → (OPTIONAL UFIX))
Returns the index of the first element matching the predicate function F.
(OPTIMUMBY F XS)
FUNCTION
∀ :A. ((:A → :A → BOOLEAN) → (LIST :A) → (OPTIONAL :A))
Returns an optimum according to a total order.
(PARTITION F XS)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (LIST :A) → (TUPLE (LIST :A) (LIST :A)))
Splits a list into two new lists. The first list contains elements matching predicate F.
(SINGLETON X)
FUNCTION
∀ :A. (:A → (LIST :A))
Returns a list containting one element.
(TRANSPOSE XS)
FUNCTION
∀ :A. ((LIST (LIST :A)) → (LIST (LIST :A)))
Transposes a matrix represented by a list of lists.
(DIFFERENCE XS YS)
FUNCTION
∀ :A. EQ :A ⇒ ((LIST :A) → (LIST :A) → (LIST :A))
Returns a new list with the first occurence of each element in YS deleted from XS.
(INSERTIONS A L)
FUNCTION
∀ :A. (:A → (LIST :A) → (LIST (LIST :A)))
Produce a list of copies of L, each with A inserted at a possible position.
(insertions 0 (make-list 1 2))
=> ((0 1 2) (1 0 2) (1 2 0))
(INTERCALATE XS XSS)
FUNCTION
∀ :A. ((LIST :A) → (LIST (LIST :A)) → (LIST :A))
Intersperses XS into XSS and then concatenates the result.
(INTERSPERSE E XS)
FUNCTION
∀ :A. (:A → (LIST :A) → (LIST :A))
Returns a new list where every other element is E.
(INTERSECTION XS YS)
FUNCTION
∀ :A. EQ :A ⇒ ((LIST :A) → (LIST :A) → (LIST :A))
Returns elements which occur in both lists. Does not return duplicates and does not guarantee order.
(REMOVE-DUPLICATES XS)
FUNCTION
∀ :A. EQ :A ⇒ ((LIST :A) → (LIST :A))
Returns a new list without duplicate elements.
EQUIVALENCE-CLASSES
[FUNCTION]
∀ :A. EQ :A ⇒ ((LIST :A) → (LIST (LIST :A)))
(EQUIVALENCE-CLASSES-BY F L)
FUNCTION
∀ :A. ((:A → :A → BOOLEAN) → (LIST :A) → (LIST (LIST :A)))
Break a list into a list of equivalence classes according to an equivalence relation.
Package coalton-library/result
result.lisp
Values
(OK? X)
FUNCTION
∀ :A :B. ((RESULT :A :B) → BOOLEAN)
Returns TRUE if X is ERR
(ERR? X)
FUNCTION
∀ :A :B. ((RESULT :A :B) → BOOLEAN)
Returns TRUE if X is ERR
(FLATTEN X)
FUNCTION
∀ :A. ((RESULT :A :A) → :A)
(MAP-ERR F X)
FUNCTION
∀ :A :B :C. ((:A → :B) → (RESULT :A :C) → (RESULT :B :C))
Map over the ERR case
Package coalton-library/cell
cell.lisp
Types
CELL :A
[TYPE]
Internally mutable cell
Instances
Values
(NEW DATA)
FUNCTION
∀ :A. (:A → (CELL :A))
Create a new mutable cell
(POP! CEL)
FUNCTION
∀ :A. ((CELL (LIST :A)) → (OPTIONAL :A))
Remove and return the first element of the list in CEL.
(READ CEL)
FUNCTION
∀ :A. ((CELL :A) → :A)
Read the value of a mutable cell
(PUSH! CEL NEW-ELT)
FUNCTION
∀ :A. ((CELL (LIST :A)) → :A → (LIST :A))
Push NEW-ELT onto the start of the list in CEL.
(SWAP! CEL DATA)
FUNCTION
∀ :A. ((CELL :A) → :A → :A)
Replace the value of a mutable cell with a new value, then return the old value
(WRITE! CEL DATA)
FUNCTION
∀ :A. ((CELL :A) → :A → :A)
Set the value of a mutable cell, returning the new value
(UPDATE! F CEL)
FUNCTION
∀ :A. ((:A → :A) → (CELL :A) → :A)
Apply F to the contents of CEL, storing and returning the result
(DECREMENT! CEL)
FUNCTION
∀ :A. NUM :A ⇒ ((CELL :A) → :A)
Subtract one from the contents of CEL, storing and returning the new value
(INCREMENT! CEL)
FUNCTION
∀ :A. NUM :A ⇒ ((CELL :A) → :A)
Add one to the contents of CEL, storing and returning the new value
(UPDATE-SWAP! F CEL)
FUNCTION
∀ :A. ((:A → :A) → (CELL :A) → :A)
Apply F to the contents of CEL, swapping the result for the old value
Package coalton-library/vector
vector.lisp
Types
VECTOR :A
[TYPE]
Instances
RUNTIMEREPR (VECTOR :A)
EQ :A ⇒ EQ (VECTOR :A)
RUNTIMEREPR :A ⇒ ISO (SLICE :A) (VECTOR :A)
RUNTIMEREPR :A ⇒ ISO (VECTOR :A) (LIST :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (SLICE :A)
RUNTIMEREPR :A ⇒ INTO (SLICE :A) (VECTOR :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (LIST :A)
RUNTIMEREPR :A ⇒ INTO (LIST :A) (VECTOR :A)
FUNCTOR VECTOR
FOLDABLE VECTOR
RUNTIMEREPR :A ⇒ SEMIGROUP (VECTOR :A)
ADDRESSABLE (VECTOR :A)
RUNTIMEREPR :A ⇒ FROMITERATOR (VECTOR :A) :A
INTOITERATOR (VECTOR :A) :A
Values
(NEW _)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ (UNIT → (VECTOR :A))
Create a new empty vector
(COPY V)
FUNCTION
∀ :A. ((VECTOR :A) → (VECTOR :A))
Return a new vector containing the same elements as V
(HEAD V)
FUNCTION
∀ :A. ((VECTOR :A) → (OPTIONAL :A))
Return the first item of V
(LAST V)
FUNCTION
∀ :A. ((VECTOR :A) → (OPTIONAL :A))
Return the last element of V
(POP! V)
FUNCTION
∀ :A. ((VECTOR :A) → (OPTIONAL :A))
Remove and return the last item of V
(SET! INDEX ITEM V)
FUNCTION
∀ :A. (UFIX → :A → (VECTOR :A) → UNIT)
Set the INDEXth element of V to ITEM. This function left intentionally unsafe because it does not have a return value to check.
(INDEX INDEX V)
FUNCTION
∀ :A. (UFIX → (VECTOR :A) → (OPTIONAL :A))
Return the INDEXth element of V
(PUSH! ITEM V)
FUNCTION
∀ :A. (:A → (VECTOR :A) → UFIX)
Append ITEM to V and resize V if necessary, returning the index of the new item.
(SORT! V)
FUNCTION
∀ :A. ORD :A ⇒ ((VECTOR :A) → UNIT)
Sort a vector inplace
(APPEND V1 V2)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ ((VECTOR :A) → (VECTOR :A) → (VECTOR :A))
Create a new VECTOR containing the elements of v1 followed by the elements of v2
(EMPTY? V)
FUNCTION
Returns TRUE if V is empty
(LENGTH V)
FUNCTION
Returns the length of V
(FOREACH F V)
FUNCTION
∀ :A :B. ((:A → :B) → (VECTOR :A) → UNIT)
Call the function F once for each item in V
(CAPACITY V)
FUNCTION
Returns the number of elements that V can store without resizing
(FOREACH2 F V1 V2)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (VECTOR :A) → (VECTOR :B) → UNIT)
Iterate in parallel over V1 and V2 calling F once for each pair of elements. Iteration stops when the shorter vector runs out of elements.
(SORT-BY! F V)
FUNCTION
∀ :A. ((:A → :A → BOOLEAN) → (VECTOR :A) → UNIT)
Sort a vector inplace with predicate function F
(FIND-ELEM E V)
FUNCTION
∀ :A. EQ :A ⇒ (:A → (VECTOR :A) → (OPTIONAL UFIX))
Find the index of element E in V
(HEAD-UNSAFE V)
FUNCTION
∀ :A. ((VECTOR :A) → :A)
Return the first item of V without first checking if V is empty
(LAST-UNSAFE V)
FUNCTION
∀ :A. ((VECTOR :A) → :A)
Return the last element of V without first checking if V is empty
(POP-UNSAFE! V)
FUNCTION
∀ :A. ((VECTOR :A) → :A)
Remove and return the last item of V without checking if the vector is empty
(ELEMENT-TYPE V)
FUNCTION
∀ :A. ((VECTOR :A) → LISPTYPE)
Returns the element type of V as a LispType
(INDEX-UNSAFE INDEX V)
FUNCTION
∀ :A. (UFIX → (VECTOR :A) → :A)
Return the INDEXth element of V without checking if the element exists
(SWAP-REMOVE! IDX VEC)
FUNCTION
∀ :A. (UFIX → (VECTOR :A) → (OPTIONAL :A))
Remove the element IDX from VEC and replace it with the last element in VEC. Then return the removed element.
(FOREACH-INDEX F V)
FUNCTION
∀ :A :B. ((UFIX → :A → :B) → (VECTOR :A) → UNIT)
Call the function F once for each item in V with its index
(WITH-CAPACITY N)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ (UFIX → (VECTOR :A))
Create a new vector with N elements preallocated
(SWAP-REMOVE-UNSAFE! IDX VEC)
FUNCTION
∀ :A. (UFIX → (VECTOR :A) → :A)
Remove the element IDX from VEC and replace it with the last element in VEC without bounds checking. Then return the removed element.
Package coalton-library/slice
slice.lisp
Types
SLICE :A
[TYPE]
Instances
RUNTIMEREPR (SLICE :A)
EQ :A ⇒ EQ (SLICE :A)
RUNTIMEREPR :A ⇒ ISO (SLICE :A) (VECTOR :A)
RUNTIMEREPR :A ⇒ INTO (VECTOR :A) (SLICE :A)
RUNTIMEREPR :A ⇒ INTO (SLICE :A) (VECTOR :A)
FOLDABLE SLICE
ADDRESSABLE (SLICE :A)
Values
(NEW START LENGTH V)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ (UFIX → UFIX → (VECTOR :A) → (SLICE :A))
Create a new slice backed by V starting at index START and continuing for LENGTH elements.
(COPY S)
FUNCTION
∀ :A. ((SLICE :A) → (SLICE :A))
Returns a new slice containg the same elements as S
(SET! INDEX ITEM S)
FUNCTION
∀ :A. (UFIX → :A → (SLICE :A) → UNIT)
Set the element at INDEX in S to ITEM
(INDEX IDX S)
FUNCTION
∀ :A. (UFIX → (SLICE :A) → (OPTIONAL :A))
Lookup the element at INDEX in S
(LENGTH S)
FUNCTION
Returns the length of S
(FOREACH F S)
FUNCTION
∀ :A :B. ((:A → :B) → (SLICE :A) → UNIT)
Call the function F once for each item in S
(FOREACH2 F S1 S2)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (SLICE :A) → (SLICE :B) → UNIT)
Iterate over S1 and S2 calling F once on each iteration
(ELEMENT-TYPE S)
FUNCTION
Returns the element type of S as a LispType
(INDEX-UNSAFE IDX S)
FUNCTION
∀ :A. (UFIX → (SLICE :A) → :A)
Lookup the element at INDEX in S without bounds checking
(ITER-CHUNKED F SIZE V)
FUNCTION
∀ :A :B. RUNTIMEREPR :A ⇒ (((SLICE :A) → :B) → UFIX → (VECTOR :A) → UNIT)
Chunked iteration over a vector. Ignores elements at the end if the vector does not evenly divide by the chunk size.
(ITER-SLIDING F SIZE V)
FUNCTION
∀ :A :B. RUNTIMEREPR :A ⇒ (((SLICE :A) → :B) → UFIX → (VECTOR :A) → UNIT)
Sliding iteration over a vector
(FOREACH-INDEX F S)
FUNCTION
∀ :A :B. ((UFIX → :A → :B) → (SLICE :A) → UNIT)
Call the function F once for each item in S with its index
Package coalton-library/hashtable
hashtable.lisp
Types
HASHTABLE :A :B
[TYPE]
A mutable hash table.
Instances
RUNTIMEREPR (HASHTABLE :A :B)
ADDRESSABLE (HASHTABLE :A :B)
HASH :A ⇒ FROMITERATOR (HASHTABLE :A :B) (TUPLE :A :B)
Values
(GET TABLE KEY)
FUNCTION
∀ :A :B. HASH :A ⇒ ((HASHTABLE :A :B) → :A → (OPTIONAL :B))
Lookup KEY in TABLE
(NEW _)
FUNCTION
∀ :A :B. HASH :A ⇒ (UNIT → (HASHTABLE :A :B))
Create a new empty hashtable
(KEYS TABLE)
FUNCTION
∀ :A :B. ((HASHTABLE :A :B) → (LIST :A))
Returns the keys in TABLE as a list
(SET! TABLE KEY VALUE)
FUNCTION
∀ :A :B. HASH :A ⇒ ((HASHTABLE :A :B) → :A → :B → UNIT)
Set KEY to VALUE in TABLE
(COUNT TABLE)
FUNCTION
∀ :A :B. ((HASHTABLE :A :B) → INTEGER)
Returns the number of entries in TABLE
(VALUES TABLE)
FUNCTION
∀ :A :B. ((HASHTABLE :A :B) → (LIST :B))
Returns the values in TABLE as a list
(ENTRIES TABLE)
FUNCTION
∀ :A :B. ((HASHTABLE :A :B) → (LIST (TUPLE :A :B)))
Returns the key-values pairs as a list.
(FOREACH F TABLE)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (HASHTABLE :A :B) → UNIT)
Call F once for each key value pair in TABLE
(REMOVE! TABLE KEY)
FUNCTION
∀ :A :B. HASH :A ⇒ ((HASHTABLE :A :B) → :A → UNIT)
Remove the entry at KEY from TABLE
(WITH-CAPACITY CAPACITY)
FUNCTION
∀ :A :B. HASH :A ⇒ (INTEGER → (HASHTABLE :A :B))
Crate a new empty hashtable with a given capacity
Package coalton-library/monad/state
monad/state.lisp
Types
ST :A :B
[TYPE]
(ST (:A → (TUPLE :A :B)))
A computation of a value which may affect the state. Represented as a closure from initial state to updated state and value.
Instances
RUNTIMEREPR (ST :A :B)
MONAD (ST :A)
FUNCTOR (ST :A)
APPLICATIVE (ST :A)
Values
GET
[VALUE]
∀ :A. (ST :A :A)
A StatefulComputation which returns the current state as the value.
(PUT STATE)
FUNCTION
A StatefulComputation with state set to be given state. The returned value is Unit.
(RUN SC)
FUNCTION
∀ :A :B. ((ST :A :B) → :A → (TUPLE :A :B))
Runs a StatefulComputation to produce a final updated state and value given an initial state
Package coalton-library/iterator
iterator.lisp
Types
ITERATOR :A
[TYPE]
A forward-moving pointer into an ordered sequence of :ELTs
Instances
RUNTIMEREPR (ITERATOR :A)
FUNCTOR ITERATOR
INTOITERATOR (ITERATOR :A) :A
Classes
FROMITERATOR
[CLASS]
FROMITERATOR :A :B
Methods:
COLLECT! :: ((ITERATOR :B) → :A)
Instances
FROMITERATOR (LIST :A) :A
RUNTIMEREPR :A ⇒ FROMITERATOR (VECTOR :A) :A
HASH :A ⇒ FROMITERATOR (HASHTABLE :A :B) (TUPLE :A :B)
ORD :A ⇒ FROMITERATOR (TREE :A) :A
ORD :A ⇒ FROMITERATOR (MAP :A :B) (TUPLE :A :B)
INTOITERATOR
[CLASS]
INTOITERATOR :A :B
Containers which can be converted into iterators.
`into-iter’ must not mutate its argument, only produce a “view” into it.
Methods:
INTO-ITER :: (:A → (ITERATOR :B))
Instances
INTOITERATOR (LIST :A) :A
INTOITERATOR (ITERATOR :A) :A
INTOITERATOR (OPTIONAL :A) :A
INTOITERATOR (RESULT :A :B) :B
INTOITERATOR (VECTOR :A) :A
INTOITERATOR STRING CHAR
INTOITERATOR (TREE :A) :A
INTOITERATOR (MAP :A :B) (TUPLE :A :B)
Values
NEW
[FUNCTION]
∀ :A. ((UNIT → (OPTIONAL :A)) → (ITERATOR :A))
Create a new iterator from a function that yields elements.
(OR! ITER)
FUNCTION
((ITERATOR BOOLEAN) → BOOLEAN)
Returns True if any iterator elements are True. May not consume the entire iterator. Returns False on an empty iterator.
(AND! ITER)
FUNCTION
((ITERATOR BOOLEAN) → BOOLEAN)
Returns True if all iterator elements are True. May not consume the entire iterator. Returns True on an empty iterator.
(ANY! GOOD? ITER)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (ITERATOR :A) → BOOLEAN)
Return True
as soon as any element of ITER is GOOD?, or False
if none of them are.
Returns False
if ITER is empty.
(MAX! ITER)
FUNCTION
∀ :A. ORD :A ⇒ ((ITERATOR :A) → (OPTIONAL :A))
Return the most-positive element of ITER, or None
if ITER is empty.
(MIN! ITER)
FUNCTION
∀ :A. ORD :A ⇒ ((ITERATOR :A) → (OPTIONAL :A))
Return the most-negative element of ITER, or None
if ITER is empty.
(SUM! ITER)
FUNCTION
∀ :A. NUM :A ⇒ ((ITERATOR :A) → :A)
Add together all the elements of ITER.
ZIP!
[FUNCTION]
∀ :A :B. ((ITERATOR :A) → (ITERATOR :B) → (ITERATOR (TUPLE :A :B)))
Return an iterator of tuples contining elements from two iterators.
EMPTY
[VALUE]
∀ :A. (ITERATOR :A)
Yields nothing; stops immediately
(FIND! THIS? ITER)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (ITERATOR :A) → (OPTIONAL :A))
Return the first element of ITER for which THIS? returns True
, or None
if no element matches.
(FOLD! FUNC INIT ITER)
FUNCTION
∀ :A :B. ((:A → :B → :A) → :A → (ITERATOR :B) → :A)
Tail recursive in-order fold. Common Lisp calls this operation reduce
.
If ITER is empty, returns INIT. Otherwise, calls (FUNC STATE ITEM) for each ITEM of ITER to produce a new STATE, using INIT as the first STATE.
(LAST! ITER)
FUNCTION
∀ :A. ((ITERATOR :A) → (OPTIONAL :A))
Yields the last element of ITER, completely consuming it.
(NEXT! ITER)
FUNCTION
∀ :A. ((ITERATOR :A) → (OPTIONAL :A))
Advance ITER, returning its next yielded value, or None
if the iterator is exhausted.
Behavior is undefined if two threads concurrently call next!
on the same iterator without a lock. Note that
most of the operators defined on iterators call next!
internally, or create new iterators which will call
next!
on their inputs.
(TAKE! COUNT ITER)
FUNCTION
∀ :A. (UFIX → (ITERATOR :A) → (ITERATOR :A))
An Iterator
which yields at most COUNT elements from ITER.
(UP-TO LIMIT)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → (ITERATOR :A))
An iterator which begins at zero and counts up to, but not including, LIMIT.
(CHAIN! ITER1 ITER2)
FUNCTION
∀ :A. ((ITERATOR :A) → (ITERATOR :A) → (ITERATOR :A))
(COUNT! ITER)
FUNCTION
Return the number of elements in ITER.
This operation could be called length!
, but count!
emphasizes the fact that it consumes ITER, and
afterwards, ITER will be exhausted.
(EVERY! GOOD? ITER)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (ITERATOR :A) → BOOLEAN)
Return True
if every element of ITER is GOOD?, or False
as soon as any element is not GOOD?.
Returns True
if ITER is empty.
(CONCAT! FIRST SECOND)
FUNCTION
∀ :A. ((ITERATOR :A) → (ITERATOR :A) → (ITERATOR :A))
Yield all the elements of FIRST followed by all the elements from SECOND.
(FILTER! KEEP? ITER)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (ITERATOR :A) → (ITERATOR :A))
Return an iterator over the elements from ITER for which KEEP? returns true.
(FLATTEN! ITERS)
FUNCTION
∀ :A. ((ITERATOR (ITERATOR :A)) → (ITERATOR :A))
Yield all the elements from each of the ITERS in order.
(ZIPWITH! F LEFT RIGHT)
FUNCTION
∀ :A :B :C. ((:A → :B → :C) → (ITERATOR :A) → (ITERATOR :B) → (ITERATOR :C))
Return an iterator of elements from LEFT and RIGHT which terminates as soon as either LEFT or RIGHT does.
(DOWN-FROM LIMIT)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → (ITERATOR :A))
An iterator which begins below the provided limit and counts down through and including zero.
(FOR-EACH! THUNK ITER)
FUNCTION
∀ :A :B. ((:A → :B) → (ITERATOR :A) → UNIT)
Call THUNK on each element of ITER in order for side effects. Discard values returned by THUNK.
(INDEX-OF! THIS? ITER)
FUNCTION
∀ :A. ((:A → BOOLEAN) → (ITERATOR :A) → (OPTIONAL UFIX))
Return the zero-based index of the first element of ITER for which THIS? is True
, or None
if no element matches.
(LIST-ITER LST)
FUNCTION
∀ :A. ((LIST :A) → (ITERATOR :A))
Yield successive elements of LST. Behavior is undefined if the iterator is advanced after a destructive modification of LST.
(OPTIMIZE! BETTER? ITER)
FUNCTION
∀ :A. ((:A → :A → BOOLEAN) → (ITERATOR :A) → (OPTIONAL :A))
For an order BETTER? which returns True
if its first argument is better than its second argument, return the best element of ITER.
Return None
if ITER is empty.
(CHAR-RANGE START END)
FUNCTION
(CHAR → CHAR → (ITERATOR CHAR))
An inclusive range of characters from START to END by cl:char-code.
(ENUMERATE! ITER)
FUNCTION
∀ :A. ((ITERATOR :A) → (ITERATOR (TUPLE UFIX :A)))
Pair successive zero-based incides with elements from ITER
(PAIR-WITH! FUNC KEYS)
FUNCTION
∀ :A :B. ((:A → :B) → (ITERATOR :A) → (ITERATOR (TUPLE :A :B)))
Returns an iterator over tuples whose FSTs are elements from KEYS, and whose SNDs are the results of applying FUNC to those KEYS.
(UNWRAPPED! ITER)
FUNCTION
∀ :A :B. UNWRAPPABLE :A ⇒ ((ITERATOR (:A :B)) → (ITERATOR :B))
(UP-THROUGH LIMIT)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → (ITERATOR :A))
An iterator which begins at zero and counts up through and including LIMIT.
(INTERLEAVE! LEFT RIGHT)
FUNCTION
∀ :A. ((ITERATOR :A) → (ITERATOR :A) → (ITERATOR :A))
Return an interator of interleaved elements from LEFT and RIGHT which terminates as soon as both LEFT and RIGHT do.
If one iterator terminates before the other, elements from the longer iterator will be yielded without interleaving. (interleave empty ITER) is equivalent to (id ITER).
(REPEAT-ITEM ITEM COUNT)
FUNCTION
∀ :A. (:A → UFIX → (ITERATOR :A))
Yield ITEM COUNT times, then stop.
(VECTOR-ITER VEC)
FUNCTION
∀ :A. ((VECTOR :A) → (ITERATOR :A))
Yield successive elements of VEC. Behavior is undefined if the iterator is advanced after a destructive modification of VEC.
(STRING-CHARS STR)
FUNCTION
Yield successive Char
s from STR.
Behavior is undefined if the iterator is advanced after a destructive modification of STR.
(COLLECT-LIST! ITER)
FUNCTION
∀ :A. ((ITERATOR :A) → (LIST :A))
Construct a List
containing all the elements from ITER in order.
(COUNT-FOREVER _)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (UNIT → (ITERATOR :A))
An infinite iterator which starts at 0 and counts upwards by 1.
ELEMENTWISE==!
[FUNCTION]
∀ :A. EQ :A ⇒ ((ITERATOR :A) → (ITERATOR :A) → BOOLEAN)
Is every element of the first iterator `==’ to the corresponding element of the second?
True if two iterators have the same length, and for every N, the Nth element of the first iterator is `==’ to the Nth element of the second iterator.
(RECURSIVE-ITER SUCC DONE? START)
FUNCTION
∀ :A. ((:A → :A) → (:A → BOOLEAN) → :A → (ITERATOR :A))
An iterator which yields first START, then (SUCC START), then (SUCC (SUCC START)), and so on, stopping as soon as such a value is done?
.
Beware off-by-one errors: the first value which is done?
is not yielded. If `(done? start)’ is true, the
iterator is empty.
(REPEAT-FOREVER ITEM)
FUNCTION
∀ :A. (:A → (ITERATOR :A))
Yield ITEM over and over, infinitely.
(COLLECT-VECTOR! ITER)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ ((ITERATOR :A) → (VECTOR :A))
Construct a Vector
containing all the elements from ITER in order.
(RANGE-DECREASING STEP START END)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → :A → :A → (ITERATOR :A))
A range which begins below START and counts down through and including END by STEP.
Equivalent to reversing range-increasing
(RANGE-INCREASING STEP START END)
FUNCTION
∀ :A. (NUM :A) (ORD :A) ⇒ (:A → :A → :A → (ITERATOR :A))
An iterator which begins at START and yields successive elements spaced by STEP, stopping before END.
(ELEMENTWISE-HASH! ITER)
FUNCTION
∀ :A. HASH :A ⇒ ((ITERATOR :A) → UFIX)
Hash an iterator by combining the hashes of all its elements.
The empty iterator will hash as 0.
(COLLECT-HASHTABLE! ITER)
FUNCTION
∀ :A :B. HASH :A ⇒ ((ITERATOR (TUPLE :A :B)) → (HASHTABLE :A :B))
Construct a HashTable
containing all the key/value pairs from ITER.
If a key appears in ITER multiple times, the resulting table will contain its last corresponding value.
(ELEMENTWISE-MATCH! SAME? LEFT RIGHT)
FUNCTION
∀ :A. ((:A → :A → BOOLEAN) → (ITERATOR :A) → (ITERATOR :A) → BOOLEAN)
Are LEFT and RIGHT elementwise-identical under SAME?
True if, for every pair of elements (A B) in (LEFT RIGHT), (same? A B) is True, and LEFT and RIGHT have the same length.
(REMOVE-DUPLICATES! ITER)
FUNCTION
∀ :A. HASH :A ⇒ ((ITERATOR :A) → (ITERATOR :A))
Yield unique elements from ITER in order of first appearance.
(COLLECT-VECTOR-SIZE-HINT! SIZE ITER)
FUNCTION
∀ :A. RUNTIMEREPR :A ⇒ (UFIX → (ITERATOR :A) → (VECTOR :A))
Construct a Vector
with initial allocation for SIZE elements, and fill it with all the elements from ITER in order.
The vector will be resized if ITER contains more than SIZE elements.
Package coalton-library/ord-tree
ord-tree.lisp
Types
TREE :A
[TYPE]
EMPTY
A red-black balanced binary tree, sorted by <=>' and unique by
==’.
Instances
Values
(MERGE A B)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → (TREE :A) → (TREE :A))
Construct a Tree containing all the elements of both A and B.
If A and B contain elements A’ and B’ respectively where (== A’ B’), the result will contain either A’ or B’. Which one is chosen for the result is undefined.
(INSERT TRE ELT)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (OPTIONAL (TREE :A)))
Construct a new Tree like TRE but containing ELT. If TRE already had an element `==’ to ELT, return None.
(LOOKUP HAYSTACK NEEDLE)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (OPTIONAL :A))
If HAYSTACK contains an element `==’ to NEEDLE, return it.
(REMOVE TRE ELT)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (OPTIONAL (TREE :A)))
Construct a new Tree like TRE but without an element ==' to ELT. Return None if TRE does not contain an element
==’ to ELT.
(REPLACE TRE ELT)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (OPTIONAL (TUPLE (TREE :A) :A)))
Construct a new Tree like TRE but with ELT replacing an old element `==’ to ELT.
Return the new tree and the removed element.
If TRE did not have an element `==’ to ELT, return None.
(COLLECT! ITER)
FUNCTION
∀ :A. ORD :A ⇒ ((ITERATOR :A) → (TREE :A))
Construct a Tree containing all the elements of ITER.
If ITER contains duplicates, later elements will overwrite earlier elements.
DECREASING-ORDER
[FUNCTION]
∀ :A. ((TREE :A) → (ITERATOR :A))
Iterate the elements of a tree, starting with the greatest by `<=>’ and ending with the least.
INCREASING-ORDER
[FUNCTION]
∀ :A. ((TREE :A) → (ITERATOR :A))
Iterate the elements of a tree, starting with the least by `<=>’ and ending with the greatest.
(INSERT-OR-REPLACE TRE ELT)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (TREE :A))
Construct a new Tree like TRE but containing ELT.
If TRE already had an element `==’ to ELT, remove it, replace it with ELT, and discard the removed value.
Like `replace-or-insert’, but prioritizing insertion as a use case.
(REPLACE-OR-INSERT TRE ELT)
FUNCTION
∀ :A. ORD :A ⇒ ((TREE :A) → :A → (TUPLE (TREE :A) (OPTIONAL :A)))
Construct a new Tree like TRE but containing ELT.
If TRE already had an element `==’ to ELT, remove it, replace it with ELT, and return the removed value alongside the new tree.
Package coalton-library/ord-map
ord-map.lisp
Types
MAP :A :B
[TYPE]
A red-black binary tree which associates each :KEY with a :VALUE, sorted by <=>' on the keys and unique by
==’ on the keys.
Instances
Values
(KEYS MP)
FUNCTION
∀ :A :B. ((MAP :A :B) → (ITERATOR :A))
Iterate over the keys in MP, sorted least-to-greatest.
EMPTY
[VALUE]
∀ :A :B. (MAP :A :B)
A Map containing no mappings.
(MERGE A B)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → (MAP :A :B) → (MAP :A :B))
Construct a Tree containing all the mappings of both A and B.
If A and B contain mappings X -> A’ and X -> B’, it is undefined whether the result maps X to A’ or B'.
Because of the possibility that A and B will map the same X to different A’ and B’, this is not an associative operation, and therefore Map cannot implement Monoid.
(INSERT MP K V)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → :B → (OPTIONAL (MAP :A :B)))
Associate K with V in MP. If MP already contains a mapping for K, return None.
(LOOKUP MP K)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → (OPTIONAL :B))
Retrieve the value associated with K in MP, or None if MP does not contain K.
(REMOVE MP K)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → (OPTIONAL (MAP :A :B)))
Remove the mapping associated with K in MP. If K does not have a value in MP, return None.
(UPDATE FUNC MP KEY)
FUNCTION
∀ :A :B. ORD :B ⇒ ((:A → :A) → (MAP :B :A) → :B → (OPTIONAL (MAP :B :A)))
Apply FUNC to the value corresponding to KEY in MP, returning a new `Map’ which maps KEY to the result of the function.
(VALUES MP)
FUNCTION
∀ :A :B. ((MAP :A :B) → (ITERATOR :B))
Iterate over the values in MP, sorted by their corresponding keys in least-to-greatest order.
(ENTRIES MP)
FUNCTION
∀ :A :B. ((MAP :A :B) → (ITERATOR (TUPLE :A :B)))
Iterate over the (key value) pairs in MP, sorted by the keys in least-to-greatest order.
(REPLACE MP K V)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → :B → (OPTIONAL (TUPLE (MAP :A :B) :B)))
Change the association of K to V in MP. If MP did not already contain a mapping for K, return None.
(COLLECT! ITER)
FUNCTION
∀ :A :B. ORD :A ⇒ ((ITERATOR (TUPLE :A :B)) → (MAP :A :B))
Construct a Map containing all the (key value) pairs in ITER.
If ITER contains duplicate keys, later values will overwrite earlier values.
(INSERT-OR-REPLACE MP K V)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → :B → (MAP :A :B))
Update MP to associate K with V.
If MP already contains a mapping for K, replace it and discard the old value.
Like `replace-or-insert’, but prioritizing insertion as a use case.
(REPLACE-OR-INSERT MP K V)
FUNCTION
∀ :A :B. ORD :A ⇒ ((MAP :A :B) → :A → :B → (TUPLE (MAP :A :B) (OPTIONAL :B)))
Update MP to associate K with V.
If MP already contains a mapping for K, replace it and return the old value.