Zena Koans #
,_, ╭──────────────────────────────────────────╮
(O,O) ─┤ Join the journey! Zena is setting out │
( ) │ from Athens to meet the legends of the │
-"-"- │ ancient world, and you're invited. Fill │
│ in a blank, and I'll show you the way. │
╰──────────────────────────────────────────╯
Athena's owl
Learn Zena by fixing small failing tests. Each koan is a test with a blank in it: fill in the blank, save, and the next koan appears. Every few lessons, a quest asks you to write a few functions of your own. By the end you'll know enough Zena for a typical Advent of Code.
The koans are written for programmers who already know a language such as JavaScript, TypeScript, Python or C#. Where Zena does something differently, a Why: comment explains the reason.
Zena's name comes from xenia, the ancient Greek custom of guest-friendship. In the koans, Zena is a wandering guest who travels the ancient world and meets its legends, starting in Athens.
Get started #
-
Install the latest Zena release by following https://zena-lang.dev/guide/install, and check it worked:
zena --versionThe koans are written for Zena 0.0.2-preview.1, the latest release. Use a release rather than a build of Zena's
mainbranch: Zena is changing fast, and a koan that passes on a release can fail on newer code. -
Download the koans and run them:
git clone https://tangled.org/markbennett.ca/zena-koans cd zena-koans zena test --watch --verboseLeave it running:
--watchchecks your answers again each time you save, and--verboseshows the screen even once everything passes. Press Ctrl+C to stop.
Solving a koan #
Zena meets a guide on each stage of her journey, starting with Athena's owl. The guide says what you're learning, and the koan to solve is just below:
,_, ╭──────────────────────────────────────────╮
(O,O) ─┤ Welcome to Athens, Zena! Before you set │
( ) │ out, I'll test what you know. Each koan │
-"-"- │ is a test with a blank: fill it in so │
│ the test passes. │
╰──────────────────────────────────────────╯
Athena's owl
koans/01_values/01_asserts.zena
› the owl asks: is it true?
fill in the blank
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0 of 36 koans done
Meditate on it, then save.
Set NO_COLOR=1 to turn off colours and clearing the screen.
Open the file it names and find the koan by its name. Each blank says the type of value that goes there:
| Blank | Replace it with |
|---|---|
__i32(), __i64() |
a whole number, such as 3 |
__f32(), __f64() |
a number with a fraction, such as 3.5 |
__bool() |
true or false |
__str() |
a string, such as 'Zena' |
__<T>() |
a value of type T, such as a record or a function |
Replace the whole blank, including the (), and save. Wrong answers are fine: they're how koans teach. If you're stuck, the top of each file links to the Zena docs that explain it.
Quests #
Each stage ends with a quest in two parts, like an Advent of Code puzzle. Its koans come first; below them are the functions to write, each with a comment saying what it should do and a throw in place of the code. Replace the throw with your own code. When a function gives the wrong answer, the koan says what it gave:
Zena's next koan: koans/01_values/08_quest_provisions_2.zena > 50,000 workers, 365 days, 200 obols a day: more than an i32 holds
payroll(50000, 365, 200) gave -644967296, but should give 3650000000
Your editor #
Any editor works. One that runs Zena's language server shows mistakes as you type: see https://zena-lang.dev/reference/language-server/.
Thanks #
The idea comes from Ruby Koans by Jim Weirich and Joe O'Brien. Want to add a koan? See CONTRIBUTING.md.