soma.cell

Builtins

Soma 3.2.4 has 252 builtins. This list is generated from the compiler (soma describe --builtins --json), so a name that is not here is not a builtin — an agent should never guess one.

BuiltinSignature
Strings
concatconcat(a, b) -> String | concat(a: List, b: List) -> List
pad_leftpad_left(s, width: Int, fill?: String) -> String
pad_rightpad_right(s, width: Int, fill?: String) -> String
splitsplit(s: String, delim: String) -> List<String>
replacereplace(s: String, old: String, new: String) -> String
containscontains(haystack: String, needle: String) -> Bool | contains(list: List, x) -> Bool | contains(m: Map, key) -> Bool
starts_withstarts_with(s: String, prefix: String) -> Bool
ends_withends_with(s: String, suffix: String) -> Bool
lowercaselowercase(s: String) -> String
uppercaseuppercase(s: String) -> String
trimtrim(s: String) -> String | trim(s: String, chars: String) -> String
sha256sha256(s: String) -> String
hmac_sha256hmac_sha256(key: String, message: String) -> String
random_tokenrandom_token(bytes?: Int) -> String
secure_eqsecure_eq(a: String, b: String) -> Bool
formatformat(fmt: String, args...) -> String
fieldsfields(s: String) -> List<String>
index_ofindex_of(s: String, sub: String) -> Int | index_of(xs: List, x) -> Int
substringsubstring(s: String, start: Int, end: Int) -> String
escape_htmlescape_html(s: String) -> String
str_lenstr_len(s: String) -> Int
str_atstr_at(s: String, i: Int) -> Int
str_eqstr_eq(a: String, b: String) -> Bool
chrchr(n: Int) -> String
ordord(s: String) -> Int
regex_countregex_count(text: String, pattern: String) -> Int
regex_matchregex_match(text: String, pattern: String) -> Int
regex_replaceregex_replace(text: String, pattern: String, replacement: String) -> String
Math
to_fixedto_fixed(x: Float, digits: Int) -> String
div_rounddiv_round(n: Int, d: Int) -> Int
floor_divfloor_div(a: Int, b: Int) -> Int
modmod(a: Int, b: Int) -> Int
divmoddivmod(a: Int, b: Int) -> [q, r]
absabs(x: Int|Float) -> Int|Float
roundround(x: Float) -> Int | round(x: Float, digits: Int) -> Float
floorfloor(x: Float) -> Int
ceilceil(x: Float) -> Int
sqrtsqrt(x: Int|Float) -> Float
sinsin(x: Int|Float) -> Float
coscos(x: Int|Float) -> Float
tantan(x: Int|Float) -> Float
atanatan(x: Int|Float) -> Float
atan2atan2(y: Float, x: Float) -> Float
asinasin(x: Float) -> Float
acosacos(x: Float) -> Float
pipi() -> Float
loglog(x: Int|Float) -> Float
lnln(x: Int|Float) -> Float
expexp(x: Int|Float) -> Float
log10log10(x: Int|Float) -> Float
powpow(base: Int|Float, exp: Int|Float) -> Float
ipowipow(base: Int, exp: Int) -> Int
minmin(a, b) -> Int|Float | min(list: List) -> Int|Float
maxmax(a, b) -> Int|Float | max(list: List) -> Int|Float
sumsum(list: List) -> Int|Float
productproduct(list: List) -> Int|Float
avgavg(list: List) -> Int|Float
parse_intparse_int(s: String, base: Int?) -> Int | ()
parse_floatparse_float(s: String) -> Float | ()
idividiv(a: Int, b: Int) -> Int
clampclamp(v, lo, hi) -> Int|Float
randomrandom() -> Float | random(max: Int) -> Int | random(min: Int, max: Int) -> Int
gcdgcd(a: Int, b: Int) -> Int
sqrt_intsqrt_int(n: Int) -> Int
pow_modpow_mod(base: Int, exp: Int, m: Int) -> Int
bandband(a: Int, b: Int) -> Int
borbor(a: Int, b: Int) -> Int
bxorbxor(a: Int, b: Int) -> Int
bnotbnot(a: Int) -> Int
shlshl(a: Int, n: Int) -> Int
shrshr(a: Int, n: Int) -> Int
bit_testbit_test(a: Int, i: Int) -> Int
bit_setbit_set(a: Int, i: Int) -> Int
bit_clrbit_clr(a: Int, i: Int) -> Int
bit_nextbit_next(a: Int, i: Int) -> Int
bit_lenbit_len(a: Int) -> Int
medianmedian(xs: List) -> Int | Float
pstdevpstdev(xs: List) -> Float
stddevstddev(xs: List) -> Float
stdevstdev(xs: List) -> Float
variancevariance(xs: List) -> Float
pvariancepvariance(xs: List) -> Float
Collections
listlist(items...) -> List
mapmap(key, value, ...) -> Map | list |> map(x => expr) -> List
pushpush(list: List, items...) -> List
nthnth(list: List, i: Int) -> Any
reversereverse(list: List) -> List
rangerange(start: Int, end: Int, step?: Int) -> List<Int>
sortsort(list: List, order?: "desc") -> List
flattenflatten(list: List) -> List
zipzip(a: List, b: List) -> List<{left, right}>
enumerateenumerate(list: List) -> List<{index, value}>
withwith(m: Map, key, value, ...) -> Map | with(list: List, i: Int, value) -> List
withoutwithout(m: Map, keys...) -> Map
mergemerge(a: Map, b: Map, ...) -> Map
joinjoin(list: List, sep: String) -> String | join(left: List, right: List, key) -> List
sliceslice(xs: List|String, start: Int, end?: Int) -> List|String
keyskeys(m: Map) -> List<String>
valuesvalues(m: Map) -> List
entriesentries(m: Map) -> List<{key, value}>
Pipelines
filter_byfilter_by(rows: List<Map>, field, value) -> List<Map> | filter_by(rows: List<Map>, field, op: ">"|">="|"<"|"<="|"=="|"!=", value) -> List<Map>
sort_bysort_by(rows: List<Map>, field, order?: "desc") -> List<Map> | sort_by(list, x => key, order?: "desc") -> List
toptop(rows: List, n: Int) -> List
bottombottom(rows: List, n: Int) -> List
sum_bysum_by(rows: List<Map>, field) -> Int | Float
avg_byavg_by(rows: List<Map>, field) -> Int|Float
min_bymin_by(rows: List<Map>, field) -> Map
max_bymax_by(rows: List<Map>, field) -> Map
pluckpluck(rows: List<Map>, field) -> List
group_bygroup_by(rows: List<Map>, field) -> Map<String, List>
distinctdistinct(rows: List, field?) -> List
distinct_bydistinct_by(rows: List<Map>, field: String) -> List<Map>
count_bycount_by(rows: List<Map>, field, value) -> Int
selectselect(rows: List<Map>, fields...) -> List<Map>
aggagg(rows: List<Map>, group_field, "col:func"...) -> List<Map>
inner_joininner_join(left: List<Map>, right: List<Map>, key) -> List<Map>
left_joinleft_join(left: List<Map>, right: List<Map>, key) -> List<Map>
Lambdas
filterfilter(list: List, x => Bool) -> List
findfind(list: List, x => Bool) -> Any
anyany(list: List, x => Bool) -> Bool
allall(list: List, x => Bool) -> Bool
countcount(list: List, x => Bool) -> Int
reducereduce(list: List, initial, p => expr) -> Any
Types and conversion
lenlen(x: String|List|Map) -> Int
to_stringto_string(x) -> String
to_intto_int(x) -> Int
to_floatto_float(x) -> Float
to_jsonto_json(x) -> String
from_jsonfrom_json(s: String) -> Any
type_oftype_of(x) -> String
is_typeis_type(value: Map, type_name: String) -> Bool
is_ais_a(value: Map, type_name: String) -> Bool
failfail(kind: String, detail?) -> never | fail(r: TryResult) -> never
Files and I/O
printprint(args...) -> ()
read_fileread_file(path: String) -> String | {error}
write_filewrite_file(path: String, content) -> Bool | {error}
read_csvread_csv(path: String, opts: Map?) -> List<Map> | {error}
to_csvto_csv(rows: List<Map>) -> String
from_csvfrom_csv(text: String, opts: Map?) -> List<Map>
write_csvwrite_csv(path: String, rows: List<Map>) -> Bool | {error}
read_filesread_files(dir: String, count: Int) -> List<{path, content}>
par_read_filespar_read_files(dir: String, count: Int) -> List<{path, content}>
word_countword_count(text: String | docs: List) -> Map<String, Int>
par_word_countpar_word_count(docs: List) -> Map<String, Int>
read_stdinread_stdin() -> String
write_strwrite_str(s: String) -> Int
Time
parse_dateparse_date(s: "YYYY-MM-DD") -> {year, month, day, weekday, epoch_day}
add_daysadd_days(date: String, n: Int) -> String
add_monthsadd_months(date: String, n: Int) -> String
days_betweendays_between(a: String, b: String) -> Int
months_betweenmonths_between(a: String, b: String) -> Int
days_in_monthdays_in_month(year: Int, month: Int) -> Int
nownow() -> Int
now_msnow_ms() -> Int
todaytoday() -> String
format_dateformat_date(ts: Int) -> String
sleepsleep(ms: Int) -> ()
HTTP client
http_gethttp_get(url: String, opts?: {timeout, max_bytes, headers}) -> Map|List|String
http_posthttp_post(url: String, body, opts?: {timeout, max_bytes, headers}) -> Map|List|String
http_puthttp_put(url: String, body, opts?) -> Map|List|String
http_patchhttp_patch(url: String, body, opts?) -> Map|List|String
http_deletehttp_delete(url: String, opts?) -> Map|List|String
ws_connectws_connect(url: String) -> Map
ws_sendws_send(msg) -> ()
linklink(addr: "host:port") -> ()
subscribesubscribe(url: String) -> ()
refusalrefusal(kind: String, detail?: String) -> Map
Web responses
htmlhtml(body) -> Response | html(status: Int, body, header_key, header_value, ...) -> Response
responseresponse(status: Int, body, header_key, header_value, ...) -> Response
redirectredirect(url: String) -> Response
ssesse(streams...) -> Response
publishpublish(stream: String, data) -> ()
Templates
load_templateload_template(path: String, key, value, ...) -> String
loadload(path: String, key, value, ...) -> String
includeinclude(path: String, key, value, ...) -> String
renderrender(template: String, key, value, ...) -> String
render_eachrender_each(rows: List<Map>, template: String) -> String
Agents and LLM calls
thinkthink(prompt: String, system?: String, opts?: {max_tokens, timeout, max_rounds, tools_allowed, requires}) -> String
think_jsonthink_json(prompt: String, system?: String, opts?: {as, max_tokens, timeout, max_rounds, tools_allowed, requires}) -> Map | the `cell type` named by `as`
hordehorde(handler, inputs: List, opts?: {concurrency, max_attempts, budget_tokens, seed, snapshot, instance, on_result, apply, on_done, on_error}) -> String
votevote(handler, input, k: Int) -> Map
horde_statushorde_status(id: String) -> Map
horde_resultshorde_results(id: String) -> List
horde_cancelhorde_cancel(id: String) -> Bool
delegatedelegate(cell: String, signal: String, args...) -> Any
set_budgetset_budget(max_tokens: Int) -> ()
tokens_usedtokens_used() -> Int
tokens_remainingtokens_remaining() -> Int
tracetrace() -> List
clear_traceclear_trace() -> ()
clear_contextclear_context() -> ()
approveapprove(action: String) -> Bool
resumeresume(wait_id: String, answer) -> Any
deliverdeliver(name: String, key, value) -> Any
waitingwaiting() -> List<Map>
cancel_waitcancel_wait(wait_id: String) -> Bool
State machines
next_idnext_id() -> Int
transitiontransition(id, target_state: String) -> {id, from, to} | transition(id, from_state: String, to_state: String) -> {id, from, to}
get_statusget_status(id) -> String
has_statehas_state(id) -> Bool
valid_transitionsvalid_transitions(id) -> List<String>
Memory
rememberremember(key, value) -> ()
recallrecall(key: String) -> Any
appendslot.append(value) -> ()
Native code
bufferbuffer(n: Int) -> Buf [native] only
buf_getbuf_get(b: Buf, i: Int) -> Int [native] only
buf_setbuf_set(b: Buf, i: Int, v: Int) -> () [native] only
buffer_fbuffer_f(n: Int) -> BufF [native] only
buf_get_fbuf_get_f(b: BufF, i: Int) -> Float [native] only
buf_set_fbuf_set_f(b: BufF, i: Int, v: Float) -> () [native] only
hashmaphashmap() -> HMap [native] only
hm_gethm_get(m: HMap, k: Int) -> Int [native] only
hm_sethm_set(m: HMap, k: Int, v: Int) -> () [native] only
hm_inchm_inc(m: HMap, k: Int) -> () [native] only
hm_lenhm_len(m: HMap) -> Int [native] only
hm_hashm_has(m: HMap, k: Int) -> Bool [native] only
strbufstrbuf(capacity?: Int) -> SBuf [native] only
sb_pushsb_push(b: SBuf, s: String) -> () [native] only
sb_push_intsb_push_int(b: SBuf, n: Int) -> () [native] only
sb_push_charsb_push_char(b: SBuf, c: Int) -> () [native] only
sb_lensb_len(b: SBuf) -> Int [native] only
sb_finishsb_finish(b: SBuf) -> String [native] only
Linear algebra and risk
matrixmatrix("1 2; 3 4") -> List<List<Float>>
matmat(rows: Int, cols: Int, values: List<Float>) -> List<List<Float>>
reshapereshape(values, rows: Int, cols: Int) -> Matrix
transposetranspose(m: Matrix) -> Matrix
shapeshape(m) -> List<Int>
matmulmatmul(a: Matrix, b: Matrix) -> Matrix
detdet(m: Matrix) -> Float
diag_sumdiag_sum(m: Matrix) -> Float
identityidentity(n: Int) -> Matrix
scalescale(m: Matrix, k) -> Matrix
flatten_matflatten_mat(m: Matrix) -> List<Float>
rowsrows(r1: List<Float>, r2: List<Float>, ...) -> List<List<Float>>
colscols(c1: List<Float>, c2: List<Float>, ...) -> List<List<Float>>
eyeeye(n: Int) -> List<List<Float>>
zeroszeros(r: Int, c: Int) -> List<List<Float>>
onesones(r: Int, c: Int) -> List<List<Float>>
diagdiag(values: List<Float>) -> List<List<Float>>
to_sampledto_sampled(A: List<List<Float>>, opts?: {max_rows, max_cols}) -> Map
sample_rowsample_row(A) -> Map
drop_sampleddrop_sampled(handle: Map) -> Bool
importance_sample_rowsimportance_sample_rows(A, opts: {samples, max_dim}) -> Map
svd_lowranksvd_lowrank(A, opts: {row_samples, col_samples, rank, max_dim}) -> Map
regress_sgdregress_sgd(A, b: List<Float>, opts: {eps, eta, lambda, max_iter, rigorous, samples_per_iter, max_dim}) -> Map
clean_covarianceclean_covariance(returns: List<List<Float>>, opts: {method: "rie"|"clip"|"raw", eta, center, max_assets, max_obs}) -> Map
impact_sqrtimpact_sqrt(qty: Float, daily_volume: Float, sigma: Float, opts?: {Y}) -> Map
quantilequantile(values: List<Float>, q: Float) -> Float
var_historicalvar_historical(returns: List<Float>, opts?: {alpha, max_obs}) -> Float
expected_shortfall_historicalexpected_shortfall_historical(returns: List<Float>, opts?: {alpha, max_obs}) -> Float
var_gaussianvar_gaussian(returns: List<Float>, opts?: {alpha, mu, sigma, max_obs}) -> Float
Internal
_coalesce_coalesce(a, b) -> Any