Skip to content

Standard Library

Sema ships with 460+ built-in functions across 21 modules, covering everything from string manipulation and file I/O to HTTP requests, regex, and cryptographic hashing.

Naming Conventions

Sema's stdlib follows consistent naming patterns:

PatternConventionExample
module/functionSlash-namespacedstring/trim, file/read, math/gcd
legacy-nameScheme compatibilitystring-append, string-length
type->typeArrow conversionsstring->symbol, list->vector
predicate?Predicate suffixnull?, list?, even?

Quick Reference

Math & Arithmetic

FunctionDescription
+, -, *, /, modBasic arithmetic
<, >, <=, >=, =Comparison
abs, min, max, pow, sqrt, logNumeric utilities
floor, ceil, round, truncateRounding
sin, cos, math/tanTrigonometry
math/asin, math/acos, math/atan, math/atan2Inverse trig
math/sinh, math/cosh, math/tanhHyperbolic
math/exp, math/log10, math/log2Exponential & logarithmic
math/gcd, math/lcm, math/quotient, math/remainderInteger math
math/random, math/random-intRandom numbers
math/clamp, math/sign, math/lerp, math/map-rangeInterpolation & clamping
math/degrees->radians, math/radians->degreesAngle conversion
even?, odd?, positive?, negative?, zero?Numeric predicates
math/nan?, math/infinite?Float predicates
pi, e, math/infinity, math/nanConstants
bit/and, bit/or, bit/xor, bit/not, bit/shift-left, bit/shift-rightBitwise operations

Strings & Characters

FunctionDescription
string-append, string-length, string-ref, substringCore string ops
str, formatConversion & formatting
string/split, string/join, string/trimSplit, join, trim
string/upper, string/lower, string/capitalize, string/title-caseCase conversion
string/contains?, string/starts-with?, string/ends-with?Search predicates
string/replace, string/index-of, string/last-index-of, string/reverseManipulation
string/chars, string/repeat, string/pad-left, string/pad-rightUtilities
string/map, string/number?, string/empty?Higher-order & predicates
string/after, string/before, string/between, string/takeSlicing & extraction
string/chop-start, string/chop-end, string/ensure-start, string/ensure-endPrefix & suffix
string/wrap, string/unwrap, string/removeWrapping & removal
string/replace-first, string/replace-lastTargeted replacement
string/snake-case, string/kebab-case, string/camel-case, string/pascal-caseCase conversion
string/headline, string/wordsHeadline & word splitting
char->integer, integer->char, char-alphabetic?, ...Character operations
string->number, number->string, string->symbol, ...Type conversions

Lists

FunctionDescription
list, cons, car, cdr, first, restConstruction & access
cadr, caddr, last, nthPositional access
length, append, reverse, rangeBasic operations
map, filter, foldl, foldr, reduce, flat-mapHigher-order functions
sort, sort-by, apply, for-eachOrdering & application
take, drop, flatten, flatten-deep, zip, partitionSublists
member, any, every, list/index-of, list/unique, list/dedupeSearching
list/group-by, list/interleave, list/chunk, frequenciesGrouping
list/sum, list/min, list/maxAggregation
list/shuffle, list/pickRandom
list/repeat, make-list, iotaConstruction
list/split-at, list/take-while, list/drop-whileSplitting
assoc, assq, assvAssociation lists
interposeInterleaving
list/reject, list/find, list/soleFiltering & searching
list/pluck, list/key-byMap extraction
list/avg, list/median, list/modeStatistics
list/diff, list/intersect, list/duplicatesSet operations
list/sliding, list/page, list/cross-joinWindowing & pagination
list/pad, list/join, list/timesPadding, joining & generation
tapUtility

Vectors

FunctionDescription
vectorCreate a vector
vector->list, list->vectorConversion

Maps & HashMaps

FunctionDescription
hash-map, get, assoc, dissoc, mergeCore map ops
keys, vals, contains?, countInspection
map/entries, map/from-entriesEntry conversion
map/map-vals, map/map-keys, map/filterHigher-order
map/select-keys, map/updateSelection & update
map/sort-keys, map/except, map/zipSorting, exclusion & zipping
hashmap/new, hashmap/get, hashmap/assoc, ...HashMap operations

Predicates & Type Checking

FunctionDescription
null?, nil?, empty?, list?, pair?Collection predicates
number?, integer?, float?, string?, symbol?, keyword?Type predicates
char?, record?, bytevector?, bool?, fn?More type predicates
map?, vector?Container predicates
promise?, promise-forced?Promise predicates
eq?, =, zero?, even?, odd?, positive?, negative?Equality & numeric
prompt?, message?, conversation?, tool?, agent?LLM type predicates

File I/O & Paths

FunctionDescription
display, println, pprint, print, print-error, println-error, newline, read-line, read-stdinConsole I/O
file/read, file/write, file/appendFile read/write
file/read-bytes, file/write-bytesBinary file I/O
file/read-lines, file/write-linesLine-based I/O
file/for-each-line, file/fold-linesStreaming line I/O
file/delete, file/rename, file/copyFile management
file/exists?, file/is-file?, file/is-directory?, file/is-symlink?File predicates
file/list, file/mkdir, file/infoDirectory operations
file/globFile globbing
path/join, path/dirname, path/basename, path/extension, path/absolutePath manipulation
path/ext, path/stem, path/dir, path/filename, path/absolute?Path predicates & components

PDF Processing

FunctionDescription
pdf/extract-textExtract all text from a PDF
pdf/extract-text-pagesExtract text per page (returns list)
pdf/page-countGet number of pages
pdf/metadataGet metadata map (:title, :author, :pages, ...)

HTTP & JSON

FunctionDescription
http/get, http/post, http/put, http/delete, http/requestHTTP methods
json/encode, json/encode-pretty, json/decodeJSON serialization

Web Server

FunctionDescription
http/serveStart an HTTP server
http/routerData-driven routing
http/ok, http/created, http/no-content, http/not-found, http/errorJSON response helpers
http/redirectHTTP redirect
http/html, http/textContent-type responses
http/streamSSE streaming
http/websocketWebSocket connections

Regex

FunctionDescription
regex/match?, regex/match, regex/find-allMatching
regex/replace, regex/replace-all, regex/splitReplacement & splitting

CSV, Crypto & Encoding

FunctionDescription
csv/parse, csv/parse-maps, csv/encodeCSV operations
uuid/v4UUID generation
base64/encode, base64/decodeBase64 encoding
base64/encode-bytes, base64/decode-bytesBinary Base64
hash/sha256, hash/md5, hash/hmac-sha256Hashing

Date & Time

FunctionDescription
time/now, time-msCurrent time
time/format, time/parseFormatting & parsing
time/date-partsDate decomposition
time/add, time/diffArithmetic
sleepDelay execution

System

FunctionDescription
env, sys/env-all, sys/set-envEnvironment variables
sys/args, sys/cwd, sys/platform, sys/os, sys/archSystem info
sys/pid, sys/tty, sys/which, sys/elapsedProcess info
sys/interactive?, sys/hostname, sys/userSession info
sys/home-dir, sys/temp-dirDirectory paths
shellRun shell commands
exitExit process

Bytevectors

FunctionDescription
bytevector, make-bytevectorConstruction
bytevector-length, bytevector-u8-ref, bytevector-u8-set!Access & mutation
bytevector-copy, bytevector-appendCopy & append
bytevector->list, list->bytevectorList conversion
utf8->string, string->utf8String conversion

Records

FunctionDescription
define-record-typeDefine a record type
record?Record predicate
typeGet record type tag

Terminal Styling

FunctionDescription
term/bold, term/red, term/green, ...Individual style functions
term/styleApply multiple styles with keywords
term/rgb24-bit true color
term/stripRemove ANSI escape codes
term/spinner-start, term/spinner-stop, term/spinner-updateAnimated spinners

Text Processing

FunctionDescription
text/chunk, text/chunk-by-separator, text/split-sentencesText chunking
text/clean-whitespace, text/strip-htmlText cleaning
text/truncate, text/word-count, text/trim-indentText utilities
text/excerpt, text/normalize-newlinesExcerpt extraction & newline normalization
prompt/template, prompt/renderPrompt templates
document/create, document/text, document/metadata, document/chunkDocument metadata

Context

FunctionDescription
context/set, context/get, context/has?Core key-value context
context/remove, context/pull, context/allRetrieval & cleanup
context/merge, context/clearBulk operations
context/withScoped overrides (auto-restores on exit)
context/push, context/stack, context/popNamed stacks
context/set-hidden, context/get-hidden, context/has-hidden?Hidden (non-logged) context

Key-Value Store

FunctionDescription
kv/open, kv/closeOpen/close a JSON-backed store
kv/get, kv/set, kv/deleteCRUD operations
kv/keysList all keys

Playground & WASM

FunctionDescription
web/user-agentBrowser user agent string (WASM only)
web/user-agent-dataStructured browser info map (Chromium only, WASM only)