Learn by Examples Catalog
Welcome to the Learn by Examples Catalog — the fastest way to see how Adesh actually looks and behaves. Instead of explaining rules in the abstract, every topic is organized into its own dedicated page featuring complete, runnable programs, verified terminal outputs, and detailed engineering breakdowns.
Concept Pages Directory
Explore complete code snippets, runtime outputs, and syntax breakdowns grouped by core language concept:
| Category | Dedicated Page | Key Concepts Covered |
|---|---|---|
| Basics & Type System | Basics, Variables & Types | Primitive types, annotations, as casting, ?? null-coalescing, type() |
| Control Flow | Conditionals & Control Flow | if/elif/else, ternary operator, 3-part for loops, do-while, forEach |
| Functions | Functions, Closures & Recursion | Function annotations, recursion, lexical closures, higher-order functions |
| Collections | Arrays, Tuples & Collections | Array indexing, map, filter, reduce, HashMap, HashSet, VecDeque |
| Object-Oriented | OOP, Structs & Extensions | class, extends, super, struct, and extend on method extension blocks |
| Enums | Enums & Pattern Matching | Algebraic enums with payload variants, structural match patterns |
| Error Handling | Error Handling & Guarding | Exception guarding with throw, try, and catch blocks |
| Memory & Teardown | Defer & Memory Management | LIFO scope cleanup via defer, borrowing references (&), ownership |
| Concurrency | Async & Parallel Concurrency | async fn, await, multi-core work-stealing Parallel.map, Parallel.reduce, Parallel.sum, Parallel.sort |
| Standard Library | Standard Library Ecosystem | Native modules: Math, Crypto (SHA-256), JSON serialization, FS |
| Algorithms | Data Structures & Algorithms | Two Sum ($O(N)$ hash lookup), LRU Cache, Graph traversal |
How to Execute Examples
Run any code snippet locally using the adesh CLI tool:
# Execute using default interpreter
adesh run my_program.adesh
# Execute using Native Cranelift JIT
adesh run --jit-native my_program.adesh
# Execute using WebAssembly
adesh run --wasm my_program.adesh
# Execute embedded unit tests
adesh run --test my_program.adesh
For additional programs, check out the Runnable Examples Catalog which indexes 100+ verified examples from the official repository.