Skip to content

Standard Library

Sema ships with 350+ built-in functions across 17 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/reverseManipulation
string/chars, string/repeat, string/pad-left, string/pad-rightUtilities
string/map, string/number?Higher-order & predicates
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, reduceHigher-order functions
sort, sort-by, apply, for-eachOrdering & application
take, drop, flatten, zip, partitionSublists
member, any, every, list/index-of, list/uniqueSearching
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

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
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, print, newline, read-lineConsole I/O
file/read, file/write, file/appendFile read/write
file/read-lines, file/write-linesLine-based 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
path/join, path/dirname, path/basename, path/extension, path/absolutePath manipulation

HTTP & JSON

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

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
hash/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