This document highlights Dana projects that go beyond simple tests and played a key role in debugging our compiler implementation.
Dana implementation in
testing/extra-hard/boohoo/boohoo.dana
BooHoo is a Turing-complete esolang created by Nikolas Spyropoulos in 2023. It features a 3D memory space of size 100 × 100 × 100 storing integer values, and all its keywords are variations of the words "boo" and "hoo".
This Dana implementation of the BooHoo interpreter differs from the original Python version in the following ways:
- Comments are not supported
- Input must be provided after the main program, separated by
--- - The program size is limited to a maximum of 1000 commands
Compile the BooHoo interpreter with:
compiler/danac.sh testing/extra-hard/boohoo/boohoo.dana -o boohooExample BooHoo programs are provided in testing/extra-hard/boohoo/programs. The corresponding examples from the original repository are shown in parentheses:
test_input.boohoo (boohoo_demos/test1.boohoo):
Takes an integer
xas input and outputsx+1andx-2after some memory movements
test_loop.boohoo (boohoo_demos/test2.boohoo):
Takes an integer as input and counts reverse until 0
test_2loop.boohoo (boohoo_demos/test4.boohoo):
Copies
2x inputto memory cell(1, 0, 0)and outputs the result
In order to run a BooHoo program simply use:
./boohoo < program.boohooFor more information about the BooHoo language check the original repository.
Dana implementation in
testing/extra-hard/travelling-salesman/tsp.dana
This project implements a Genetic Algorithm (GA) to solve the classic Travelling Salesman Problem (TSP) in Dana.
- Problem setup:
- The distance matrix between cities is randomly initialized.
- Each chromosome represents a possible tour (path through all cities).
- Random number generation:
- A simple linear congruential generator (LCG) is implemented as
nextRand. - It uses constants
a = 1664525,b = 1013904223, andc = 2147483647. - This ensures reproducible pseudo-randomness for distance initialization, population shuffling, mutation, and selection.
- A simple linear congruential generator (LCG) is implemented as
- Core GA operations implemented:
fitness: Evaluates the total distance of a tour.select_parent: Tournament selection between two candidates.crossover: Order-based crossover that preserves city visits.mutate: Random swap mutation with configurable probability.
- Execution flow:
- The algorithm initializes a random population using Fisher–Yates shuffling.
- For each generation, the best solution is tracked and logged.
- New generations are produced via crossover and mutation, with elitism ensuring the best path survives.
- Output:
- Prints the best distance and corresponding path for each generation.
- At the end, outputs the globally best solution found across all generations.
This implementation showcases how Dana can handle arrays, modular function design, pseudo-random number generation, and evolutionary algorithms, while providing a structured, extendable solution for combinatorial optimization problems.
Dana implementation in
testing/extra-hard/perceptron/perceptron.dana
The classic Perceptron binary classifier implemented as a Dana test to debug our compiler's array implementation.
- The model is trained and evaluated on basic logic gates, demonstrating successful learning of both OR and AND functions.
- All calculations use fixed-point arithmetic to simulate decimal precision.
- Both
trainandpredictfunctions are provided, making the implementation structured, modular, and easy to extend.
Dana implementation in
testing/extra-hard/sudoku/sudoku.dana
This project is a complete 9×9 Sudoku solver implemented in Dana using classic backtracking with constraint checks.
It reads a 9×9 grid of integers (use 0 for blanks), solves it recursively, and prints either the solved grid or No solution.
-
Board representation:
int[9][9]. -
Printing:
printBoard(b)prints the grid row by row with spaces. -
Feasibility checks:
isSafe(b, row, col, num)ensures:numnot already inrow,numnot already incol,numnot already in the 3×3 sub-box containing(row, col).
-
Empty-cell search:
findEmpty(b, rowRef, colRef)scans for the next0. It returns a byte flag and writes the location intorowRef/colRef. -
Backtracking core:
solve(b)finds an empty cell; if none, we’re done. Otherwise, it triesnum = 1..9, and for each safe number:- place it,
- recurse,
- if recursion fails, backtrack (reset to
0) and try the next number.
This mirrors the canonical DFS search on Sudoku’s state space with pruning via row/col/box checks.
Use the compiler:
compiler/danac.sh testing/extra-hard/sudoku/sudoku.dana -o sudokuRun by piping a 9×9 grid (zeros for empty) into the executable:
./sudoku < testing/extra-hard/sudoku/sudoku.inputDana implementation in
testing/extra-hard/matrix-mul/matrix_mul.dana
This program implements standard matrix multiplication C(n×p) = A(n×m) × B(m×p) with dimensions up to 20×20.
- Matrix input/output:
readMatrix(rows, cols, M)reads integers row-wise into a 2D array.writeMatrix(rows, cols, M)prints the matrix with space-separated values.
- Matrix multiplication core:
matmul(n, m, p, A, B, C)performs the triple loop multiplication with accumulation intoC.
- Execution flow:
- Reads matrix sizes
n, m, p(capped at 20). - Reads matrix
A (n×m)andB (m×p). - Computes product
C = A × B. - Outputs the resulting matrix
C (n×p).
- Reads matrix sizes
Compile with:
compiler/danac.sh testing/extra-hard/matrix-mul/matrix_mul.dana -o matrix_mulRun and provide dimensions and elements via standard input:
./matrix_mul < testing/extra-hard/matrix-mul/matrix_mul.input