Examples
64 verified example programs
Nevaarize ships with 64 example programs covering algorithms, async,
benchmarks, modules, and real-world patterns. All examples are in the
examples/ directory.
Only scripts listed on this page (inside the examples/ directory)
have been verified to run correctly. Scripts written outside these
examples may work for similar patterns, but are not guaranteed to be free of
issues. See examples/verification_report.txt for full test results.
Standalone Examples
| File | Description |
|---|---|
basics.nva |
Variables, operators, control flow, functions, arrays |
advanced.nva |
Iterative algorithms and complex array operations |
asyncAwait.nva |
Async/await pattern demonstration |
concurrentStress.nva |
Concurrent stress testing (fan-out, GC pressure, etc.) |
exceptionDemo.nva |
Try/catch/finally and exception handling |
gcDemo.nva |
Garbage collector behavior demonstration |
mapDemo.nva |
Map (hash table) operations |
modelInference.nva |
AI model training and inference demo |
Running an Example
./bin/nevaarize examples/basics.nva
Algorithms (algorithm/)
15 algorithm implementations covering sorting, searching, math, and more:
| File | Description |
|---|---|
algorithm/arrayManipulation.nva |
Reverse, rotation, prefix sum, min/max |
algorithm/binarySearch.nva |
Binary search with lower/upper bound |
algorithm/bitwiseOps.nva |
Popcount, power-of-2, binary conversion |
algorithm/bubbleSort.nva |
Bubble sort and cocktail shaker sort |
algorithm/dynamicProgramming.nva |
Climbing stairs, Kadane's algorithm, LIS |
algorithm/floatingPoint.nva |
Newton's sqrt, integer sqrt, modular power |
algorithm/geometry.nva |
Distance, triangle area, bounding box, collinearity |
algorithm/insertionSort.nva |
Insertion sort and selection sort |
algorithm/linearSearch.nva |
Linear search, sentinel search, count occurrences |
algorithm/mathBasics.nva |
Factorial, fibonacci, power, summation |
algorithm/matrixOps.nva |
Matrix add, multiply, transpose, trace |
algorithm/numberTheory.nva |
GCD, LCM, primality test |
algorithm/primeGeneration.nva |
Prime factor, divisor count, prime check |
algorithm/stackQueue.nva |
Stack (LIFO) and Queue (FIFO) with arrays |
algorithm/twoPointers.nva |
Pair sum, Dutch national flag, merge sorted |
Benchmarks (benchmarks/)
| File | Description |
|---|---|
benchmarks/benchmark.nva |
Full benchmark suite (integer, float, control flow, function call, array) |
Run Benchmarks
./bin/nevaarize examples/benchmarks/benchmark.nva
Modules (modules/)
Demonstrates the module import system with multi-file project structure:
| File | Description |
|---|---|
modules/main.nva |
Entry point that imports and uses other modules |
modules/config/settings.nva |
Configuration module |
modules/lib/math.nva |
Custom math utilities (square, cube, abs, etc.) |
modules/lib/arrays.nva |
Array helper functions (sum, max, min) |
modules/lib/strings.nva |
String manipulation utilities |
modules/lib/utils/logger.nva |
Nested logging utility module |
Rich Code Samples (richcodesample/)
25 advanced examples demonstrating complex patterns and real-world use cases:
| File | Description |
|---|---|
richcodesample/asyncOrchestrator.nva |
Parallel task orchestration with async |
richcodesample/bitOps.nva |
Bit manipulation operations |
richcodesample/cryptoSystem.nva |
Caesar cipher and crypto simulation |
richcodesample/dataProcessor.nva |
CSV-like data processing pipeline |
richcodesample/dataStructures.nva |
Linked list, tree, and graph structures |
richcodesample/expressionParser.nva |
Mathematical expression parser |
richcodesample/gameOfLife.nva |
Conway's Game of Life simulation |
richcodesample/graphAlgorithms.nva |
Graph traversal (BFS, DFS) |
richcodesample/imageFilters.nva |
Image filter simulation with matrices |
richcodesample/jsonValidator.nva |
JSON structure validation |
richcodesample/knnClassifier.nva |
K-Nearest Neighbors classifier |
richcodesample/linearRegression.nva |
Simple linear regression |
richcodesample/mandelbrot.nva |
Mandelbrot set ASCII renderer |
richcodesample/matrixOps2.nva |
Extended matrix operations |
richcodesample/monteCarlo.nva |
Monte Carlo Pi estimation |
richcodesample/neuralNetwork.nva |
Simple neural network from scratch |
richcodesample/numberTheory.nva |
Advanced number theory algorithms |
richcodesample/physicsSim.nva |
Physics simulation (projectile motion) |
richcodesample/producerConsumer.nva |
Producer-consumer pattern with async |
richcodesample/recursiveComp.nva |
Recursive computation patterns |
richcodesample/sortingBattle.nva |
Sorting algorithm comparison |
richcodesample/stringToolkit.nva |
String manipulation toolkit |
richcodesample/sudokuSolver.nva |
Sudoku solver with backtracking |
richcodesample/textSearch.nva |
Text search and pattern matching |
richcodesample/vectorEngine.nva |
Vector math engine (dot product, etc.) |
The richcodesample/ directory also includes multi-file modular examples:
richcodesample/modular/— Modular app with models and utilsrichcodesample/deepModular/— Deeply nested module imports
Stdlib Tests (stdlibtest/)
| File | Description |
|---|---|
stdlibtest/stdCsv/stdCsv.nva |
CSV stdlib module test |
stdlibtest/stdJson/stdJson.nva |
JSON stdlib module test |
stdlibtest/stdString/stdString.nva |
String stdlib module test |
Quick Code Samples
Basics
// examples/basics.nva (excerpt)
x = 42
pi = 3.14
name = "Nevaarize"
func add(a, b) {
return a + b
}
print("add(7, 3):", add(7, 3))
Fibonacci (from algorithm/mathBasics.nva)
// Iterative fibonacci
func fib(n) {
if (n <= 1) {
return n
}
a = 0
b = 1
for (i in Range(2, n + 1)) {
temp = a + b
a = b
b = temp
}
return b
}
print("fib(10) =", fib(10)) // 55
print("fib(20) =", fib(20)) // 6765
Bubble Sort (from algorithm/bubbleSort.nva)
func bubbleSort(arr) {
n = len(arr)
for (i in Range(0, n)) {
for (j in Range(0, n - i - 1)) {
if (arr[j] > arr[j + 1]) {
temp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = temp
}
}
}
return arr
}
data = [64, 34, 25, 12, 22, 11, 90]
bubbleSort(data)