CX+AI

CX in 30 Lines

The smallest useful summary of CX

GENERATED from DOCS/reference/manuals/CX_Cheatsheet_Mini.html by tests/forge.cx — edit the source, not this page.

CX in 30 lines

CX is C-shaped with type suffixes. No malloc, no pointers, no #include.

.i int  .s string  .f float  .v void

x.i = 0;          n = n + 1;          #define N 32

if cond { ... } else if c2 { ... } else { ... }   // no parens around cond
while cond { ... }    break;    continue;

array nums.i[N];        nums[i] = 5;       // 0-indexed
list xs.s;              listAdd(xs, "x"); xs->count; listGet(xs);
map m.i;                mapPut(m, "k", 1); mapGet(m, "k");
queue q.i;              queueInit(q, cap, 1);   // 0=REJECT 1=ROLL; cap can be data
                        queuePush(q, 5); queueTake(q); // oldest=FIFO; queuePop=newest=LIFO
                        while q->count > 0 { print(queueTake(q)); }
foreach xs { v.s = listGet(xs); print(v); }

function f.i(a.i, b.s) { return a + len(b); }
function g.v(s.s) { print(s); return; }     // void: bare return
fp = &f;       result = fp(10, "hi");

Builtins: print, printf, len, mid (1-INDEXED!), left, right, asc, chr, str, vali, ucase, lcase, instr, random, elapsed, delay.

Pragmas: #pragma appname "X", #pragma console on.

Pitfalls: mid() is 1-indexed; arrays 0-indexed. No outer parens on if. Containers (list/map/queue/array-passed-to-a-function) are BYREF — the callee mutates the caller's container.