Builtin Functions Index
All builtin functions in meta-lisp, categorized by functionality.
- Generic
- Boolean
- Integer
- Float
- Text
- Symbol
- Void
- Array
- List
- Set
- Hash table
- Pair
- Maybe
- Box
- Function operations
- for- Iteration
- File I/O
- Path operations
- Assertions
- Error handling
- Process
- Random
- Format
- S-expression
- JSON
Generic
Operations applicable to all types.
is-atom— Check if a value is an atomsame— Atom or reference equalityequal— Structural equalityformat— Format any value as a texthash-code— Compute hash codetotal-compare— Total order comparison
Boolean
Operations on bool-t.
Integer
Operations on int-t.
Type check
is-int— Check if a value is an integer
Arithmetic
ineg— Negationiadd— Additionisub— Subtractionimul— Multiplicationidiv— Integer divisionimod— Modulo
Predicates
int-is-positive— Check if positiveint-is-non-negative— Check if non-negativeint-is-non-zero— Check if non-zero
Comparisons
int-less— Less thanint-greater— Greater thanint-less-or-equal— Less than or equalint-greater-or-equal— Greater than or equalint-compare-ascending— Ascending comparison functionint-compare-descending— Descending comparison function
Extremum
Derived
int-sum— Sum of a listint-product— Product of a listint-align— Align to a multiple
Float
Operations on float-t.
Type check
is-float— Check if a value is a float
Arithmetic
Predicates
float-is-positive— Check if positivefloat-is-non-negative— Check if non-negativefloat-is-non-zero— Check if non-zero
Comparisons
float-less— Less thanfloat-greater— Greater thanfloat-less-or-equal— Less than or equalfloat-greater-or-equal— Greater than or equalfloat-compare-ascending— Ascending comparison functionfloat-compare-descending— Descending comparison function
Extremum
Derived
float-sum— Sum of a listfloat-product— Product of a list
Text
Operations on text-t.
Type checks
is-text— Check if a value is a texttext-is-int— Check if text is integer formattext-is-float— Check if text is float format
Basics
text-length— Lengthtext-is-empty— Check if emptytext-is-blank— Check if blank
Concatenation and splitting
text-append— Append two stringstext-concat— Concatenate a list of stringstext-slice— Extract substringtext-split— Split by delimitertext-join— Join with delimiter
Search and replace
text-has-prefix— Check if text has prefixtext-has-suffix— Check if text has suffixtext-include— Check if text contains substringtext-find-index— Find substring positiontext-replace— Replace substring
Trimming
text-trim— Trim both endstext-trim-start— Trim starttext-trim-end— Trim endtext-trim-left— Trim lefttext-trim-right— Trim right
Case conversion
text-to-lower-case— Convert to lower casetext-to-upper-case— Convert to upper case
Type conversion
text-to-int— Parse text to integertext-to-float— Parse text to floattext-to-symbol— Convert text to symbol
Characters and code points
text-chars— Split into character listtext-get-code-point— Get code pointtext-lines— Split into lines
Derived
text-repeat— Repeat a texttext-compare-lexical— Lexicographic comparison
Symbol
Operations on symbol-t.
is-symbol— Check if a value is a symbolsymbol-length— Length of symbol namesymbol-append— Append two symbolssymbol-concat— Concatenate a list of symbolssymbol-to-text— Convert to text
Void
is-void— Check if a value is void
Array
Operations on (array-t E) — mutable arrays.
Type and construction
array-t— Array type constructormake-array— Create an empty arrayis-array— Check if a value is an array(@array ...)— Array literal
Access
array-get— Get element by indexarray-length— Array lengtharray-is-empty— Check if empty
Mutation
array-put— Replace at indexarray-push— Append at endarray-pop— Pop from endarray-push-front— Prepend at frontarray-pop-front— Pop from frontarray-reverse— Reverse in-placearray-sort— Sort in-place with comparator
Copy and conversion
array-copy— Copy an arrayarray-to-list— Convert to listlist-to-array— Convert from list
Iteration
array-each— Iterate with side effectsarray-each-index— Iterate with index
List
Operations on (list-t E) — immutable lists.
Type and construction
list-t— List type constructornull— The empty listis-list— Check if a value is a listcons— Prepend an element
Access
car— First elementcdr— Rest of the listlist-head— First element (same ascar)list-rest— Rest of the list (same ascdr)list-first— First elementlist-second— Second elementlist-third— Third elementlist-last— Last elementlist-but-last— All but last elementlist-get— Get element by index
Info
list-length— List lengthlist-is-empty— Check if emptylist-has— Check if list has element
Transformation
list-copy-put— Replace at index (immutable)list-copy-reverse— Reverselist-to-set— Convert to set
Generation
list-range— Generate integers from 0 to n - 1list-enumerate— Pair elements with indices
Iteration and mapping
list-each— Iterate with side effectslist-each-index— Iterate with indexlist-map-concat— Map and flattenlist-map-index-concat— Map with index and flattenlist-map— Map over elementslist-map-index— Map with indexlist-zip-map— Map over two lists in parallellist-zip— Pair elements by positionlist-unzip— Unzip pairslist-filter— Filter (keep matching)
Folding
list-fold-left— Left foldlist-fold-left-index— Left fold with indexlist-fold-right— Right foldlist-fold-right-index— Right fold with index
Quantification
list-every— All elements satisfy predicatelist-some— Some element satisfies predicate
Sublists
list-take— Take first nlist-drop— Drop first nlist-append— Append two listslist-concat— Concatenate list of lists
Grouping and search
list-group— Group by predicatelist-find— Find first matching elementlist-find-index— Find first matching index
Set
Operations on (set-t E).
Type and construction
Info
set-size— Set sizeset-is-empty— Check if emptyset-has— Check if set has elementset-include— Check if set includes subset
Mutation
set-copy— Copy a setset-add— Add element (mutable)set-copy-add— Add element (immutable)set-delete— Delete element (mutable)set-copy-delete— Delete element (immutable)set-clear— Clear set (mutable)
Set operations
set-union— Unionset-inter— Intersectionset-difference— Differenceset-disjoint— Check if disjoint
Iteration and transformation
set-each— Iterate with side effectsset-every— All elements satisfy predicateset-some— Some element satisfies predicateset-map— Map over elementsset-select— Filterset-reject— Opposite of filterset-to-list— Convert to list
Hash table
Operations on (hash-t K V).
Type and construction
hash-t— Hash table type constructormake-hash— Create empty hash tablemake-hash-from-entries— Build hash from pair list
Info
hash-is-empty— Check if emptyhash-length— Entry counthash-has— Check if contains key
Access
hash-get— Get value by keyhash-get-maybe— Get value as maybe
Conversion
hash-keys— Get key listhash-values— Get value listhash-entries— Get entry list
Mutation
hash-put— Add key-value pair (mutable)hash-copy-put— Add key-value pair (immutable)hash-put-entries— Put entries (mutable)hash-copy-put-entries— Put entries (immutable)hash-delete— Delete by key (mutable)hash-copy— Copy hash table
Iteration
hash-each— Iterate over key-value pairshash-each-key— Iterate over keyshash-each-value— Iterate over valueshash-each-entry— Iterate over entries
Mapping
hash-map— Map over key-value pairshash-map-key— Map over keyshash-map-value— Map over valueshash-map-entry— Map over entries
Selection
hash-select— Filter by key-value predicatehash-select-key— Filter by key predicatehash-select-value— Filter by value predicatehash-reject— Remove by key-value predicatehash-reject-key— Remove by key predicatehash-reject-value— Remove by value predicate
Aggregation
hash-append— Merge two hash tableshash-invert— Swap keys and valueshash-invert-group— Invert with value grouping
Pair
Operations on (pair-t A B).
pair-t— Pair type constructormake-pair— Construct a pairpair-first— First elementpair-second— Second elementpair-put-first— Replace first elementpair-put-second— Replace second element
Maybe
Operations on (maybe-t A).
maybe-t— Maybe type constructorjust— Construct a present valuenothing— Represent a missing valueis-just— Check if justis-nothing— Check if nothingjust-value— Extract value from justjust-put-value— Replace value in just
Box
Operations on the opaque type (box-t E).
box-t— Box type constructormake-box— Create an empty boxbox-is-empty— Check if emptybox-put— Store a valuebox-get-maybe— Get value as maybebox-get— Get value (error if empty)
Function operations
Higher-order function manipulation.
constant— Return first argumentidentity— Return argument unchangedswap— Swap function argumentsdrop— Ignore first argumentdup— Duplicate argument
File I/O
File handle read/write operations.
Type
file-t— File handle type
Open and close
open-input-file— Open file for readingopen-output-file— Open file for writingfile-close— Close file
Read and write
file-read— Read entire filefile-write— Write a textfile-writeln— Write a text with newline
Convenience
use-input-file— Auto-closing readuse-output-file— Auto-closing write
Standard output
Path operations
Path text manipulation and file system functions.
path-file-name— Get file namepath-directory-name— Get directory namepath-extension— Get file extensionpath-stem— Get file stempath-is-absolute— Check if absolutepath-is-relative— Check if relativepath-join— Join pathspath-normalize— Normalize pathpath-relative— Compute relative pathpath-relative-to-cwd— Relative to current working directorypath-resolve— Resolve to absolute path
Query
path-exists— Check if path existspath-is-file— Check if path is a filepath-is-directory— Check if path is a directory
Read and write
path-read— Read filepath-write— Write file
Directory operations
path-list— List directory contentspath-list-recursive— List directory recursivelypath-ensure-file— Ensure file existspath-ensure-directory— Ensure directory exists
Delete and rename
path-delete-file— Delete filepath-delete-directory— Delete empty directorypath-delete— Delete recursivelypath-rename— Rename
Assertions
Assertion functions for testing.
assert— Assert condition is trueassert-not— Assert condition is falseassert-equal— Assert two values are equalassert-not-equal— Assert two values are not equal
Error handling
error— Throw an error
Process
exit— Exit with a codecurrent-directory— Get current directorycurrent-command-line— Get command line after--current-full-command-line— Get full command linecurrent-stdout-file— Get current stdout file handlecurrent-stderr-file— Get current stderr file handle
Random
random-int— Random integerrandom-float— Random float
Format
Type-specific S-expression formatting functions.
format-as-sexp— Format an arbitrary value as an S-expressionformat-int— Format an integerformat-float— Format a floatformat-symbol— Format a symbolformat-bool— Format a boolformat-text— Format a textformat-void— Format void
S-expression
S-expression parsing, formatting, and related types.
Types
sexp-t— Located S-expression typesource-location-t— Source location typesource-span-t— Source span typesource-position-t— Source position type
Operations
parse-sexps— Parse to located S-expressionsformat-sexp— Format an S-expression
JSON
JSON values and operations.
Type
json-t— JSON value type
Parse and format
parse-json— Parse a JSON textformat-json— Format as a JSON text