CX+AI

CX+AI in 30 Lines

The smallest useful summary of CX+AI

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 { ... }   // C parens, ALWAYS
while (cond) { ... }    break;    continue;
for (i.i = 0; i < n; i = i + 1) { ... }               // C-style for, unchanged
// write `x = x + 1` (works everywhere); `x++` / `x += n` only on a plain number

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 + strlen(b); }
function g.v(s.s) { print(s); return; }     // void: bare return
fp = &f;       result = fp(10, "hi");

Builtins: print, printf, strlen, substr (0-based), left, right, asc, chr, str, toupper, tolower, strstr (-1 = absent), random, elapsed, delay.

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

Pitfalls: everything counts from 0, strings included; a cast converts, (int)s / (string)n. No outer parens on if. Containers (list/map/queue/array-passed-to-a-function) are BYREF — the callee mutates the caller's container.