summaryrefslogtreecommitdiff
path: root/examples/runtime.ts
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2025-11-06 21:12:44 -0800
committerKai Stevenson <kai@kaistevenson.com>2025-11-06 21:12:44 -0800
commitcc8eeeb482f279c80ebef17fc5968e73a51b48b8 (patch)
treeab1ae00741148e617af41c57a285e74a6cd5d43d /examples/runtime.ts
parentccaff310c85a64a852d96ee71ecf9640de57ea36 (diff)
add examples
Diffstat (limited to 'examples/runtime.ts')
-rw-r--r--examples/runtime.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/runtime.ts b/examples/runtime.ts
new file mode 100644
index 0000000..2a1555c
--- /dev/null
+++ b/examples/runtime.ts
@@ -0,0 +1,15 @@
+/*
+KaiScript isn't just a pretty face (IDE hint), it's also a full and complete interpreted language.
+Any program you write in KaiScript will return exactly what it says it will.
+*/
+
+import { evaluate, lex, parse } from "../src";
+
+// First, hover over myArray in your IDE...
+// const myArray: [[1, 2, 3, 4, 5]]
+const myArray = evaluate(parse(lex(`arr(1,2,3,4,5)`)));
+
+// ...then run this file to see that the output matches
+console.log(myArray);
+
+// It's a nested tuple because all KaiScript programs are arrays. That is, the program <5, 3> would return [5, 3]