Skip to content

Grapa System Functions Quick Reference

Core Language

rule, ruleval, ruleref, token, grammar, reset, shell, eval, exec, post, sleep, exit, getenv, putenv, setenv, include

Variables & Scope

name, getname, lit, ref, setnull, var, assign, assignappend, assignextend, global, parent, this, local, constexpr, freeze, setfreeze

Data Structures

createarray, createtuple, createlist, createxml, createel, createtag, createop, createcode, createrule, extend, remove, prepend, pop, call

Search & Analysis

search, findall, sort, argsort, unique, group

Control Flow

return, break, if, while, scope, switch, case, plan, wrap, op

Functional Programming

map, reduce, filter, range

Note: map and filter are parallel by default and robust for ETL workloads; reduce is sequential. All are production-ready for high-throughput data processing.:

Type & I/O

isint, iferr, message, string, echo, console, prompt

Cryptography

Mathematical: genprime([safe]), staticprime, isprime, isaks, random, setbit, clearbit, genbits OpenSSL-Based: genkeys, encode, encoderaw, decode, sign, signadd, verify, verifyrecover, secret

Math - Basic

setfloat, setfix, root, pow, mod, modpow, modinv, abs, gcd, e, pi, ln, log, add, sub, mul, div

Math - Trigonometry

sin, cos, tan, cot, sec, csc, asin, acos, atan, acot, asec, acsc

Math - Hyperbolic

sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch

Math - Special

atan2, hypot

Bit Operations

bsl, bsr, bor, band, or, and, xor, inv

Matrix Operations

t, rref, det, rank, solve, cov, neg

Type Conversion

bits, bytes, len, bool, not, int, raw, base, str, list, array, vector, xml, float, fix, time, type, describe

String Operations

left, right, mid, midtrim, rtrim, ltrim, trim, rrot, lrot, rpad, lpad, reverse, replace, grep, split, join, lower, upper

String Distance & Similarity

.similarity() - Unified method supporting all string similarity and distance algorithms - String-to-string: "hello".similarity("hallo", "levenshtein") - Array similarity: ["hello", "world"].similarity("query", "cosine") - Parameters: top_n, threshold, sort, include_scores, include_items

Array/Matrix

shape, reshape, dot, identity, diagonal, triu, tril, eigh, sum, mean

Vector Operations

.similarity() - Unified method supporting all vector similarity and distance algorithms - Vector-to-vector: vec1.similarity(vec2, "cosine") - Array similarity: [vec1, vec2, vec3].similarity(query_vec, "euclidean") - Parameters: top_n, threshold, sort, include_scores, include_items

Comparison

eq, neq, gteq, gt, lteq, lt, cmp

Time

utc, tz

System

getenv, putenv, setenv, freeze, setfreeze, compile, compilef, eval, sleep

Command Line Arguments: $ARGV (positional args), $CLIARGV (full command line)

File System

Navigation: file_pwd (working dir), file_cd (change working dir), file_phd (home dir), file_chd (change home dir) Operations: file_ls, file_mk, file_rm, file_set, file_get, file_info (metadata: type, size, existence) Database: file_table, file_mkfield, file_rmfield, file_split (split large files), file_dump

Networking

net_mac, net_interfaces, net_connect, net_bind, net_listen, net_onlisten, net_disconnect, net_proxy, net_certificate, net_private, net_trusted, net_verify, net_chain, net_host, net_send, net_receive, net_pending, net_onreceive

HTTP

http_read, http_send, http_message

Threading

thread_trylock, thread_lock, thread_unlock, thread_wait, thread_signal, thread_waiting, thread_start, thread_stop, thread_started, thread_suspend, thread_resume, thread_suspended

GUI Widgets

widget_new, widget_show, widget_hide, widget_redraw, widget_resizable, widget_resize, widget_parent, widget_child, widget_next, widget_focus, widget_get, widget_set, widget_handle, widget_callback, widget_event_key, widget_append, widget_post, widget_clear

OOP

class, obj

Usage

// Direct call
result = $sys.function_name(params);

// In BNF grammar
expression = $sys.add(term, expression);

// In library files
function = op(){@$this.$sys.function_name(@var.{params});};

Object Inspection and Reflection

describe(options)

Provides comprehensive object description and reflection capabilities.

Parameters: - options (optional): Configuration object - properties (boolean): Include property names (default: true) - methods (boolean): Include method names (default: true) - structure (boolean): Include internal structure (default: false) - values (boolean): Include actual values (default: false) - format (string): Output format - "text", "json" (default: "text")

Examples:

'hello'.describe();                    /* "String with length 5" */
(123).describe();                      /* "Integer: 123" */
[1,2,3].describe();                    /* "Array with 3 elements" */
{name:'Alice'}.describe();             /* "List with 1 properties (keys: name)" */
(2.3).describe({structure:true});      /* Shows 7 float components */
'world'.describe({values:true});       /* "String with length 5: \"world\"" */
{name:'Bob'}.describe({format:'json'}); /* {"type":"list","length":1,"properties":1,"keys":["name"]} */

type()

Returns the type of an object.

Examples:

'hello'.type();    /* $STR */
123.type();        /* $INT */
[1,2,3].type();    /* $LIST */
{name:'Alice'}.type(); /* $GOBJ */

Total: 200+ system functions available

See Also: - Getting Started - JS-to-Grapa Migration Guide - Examples