This is part 7, the last numbered part. It does two things: shows you one program that uses everything parts 1–6 taught, so you can measure how much that now is — and then hands you the map, because from here the path fans out into themed tutorials that no single order serves.
The example is examples/Crossroads
in the tutorial repository. It reads starting points from a file and walks
each one by part 4’s halve-or-triple rule:
make -C examples/Crossroads runCrossroads
start steps highest
7 16 52
27 111 9232
not a number: peak?
97 118 9232Read the table twice. The third line is a data line that was not a number, reported and skipped. And 97’s walk is neither 27’s prefix nor its scale — yet both funnel through the same summit, 9232. Different roads, one mountain pass; the walk is stranger than parts 4 and 5 let on.
What you can now read
Everything in this program is parts 1–6, plus one new thing:
type
Walk = record
start, steps, peak : int64;
end;A record gathers named facts under one name — exactly what part 5’s
WalkFrom wanted when it had two facts to return and had to borrow your
variable for the second. Now it answers all three as one value:
function WalkFrom(from : int64) : Walk;and the value rule you already know extends whole: assigning a record copies
all of it. The caller’s w is the function’s answer, nobody’s alias.
The rest you have seen: the while and the if are part 4’s; the function
with its own locals is part 5’s; the Open … on fail caught do with
Enoent answered by name, the defer Close, and the ReadLine loop are
part 6’s. One new spelling — on fail use False — gives a fallible read a
visible default instead of a handler: if the wire to the file breaks
mid-loop, the loop simply ends. And notice the two kinds of “no” sitting
side by side: a file that cannot be opened is a failure, with a channel
and a name; a line that is not a number is just an answer — Val returns
False and the program moves on. Mica keeps those apart on purpose, and the
error philosophy page is where that line is drawn
properly.
Try it
1. Feed it a monster. Add 6171 to starts.txt and re-run:
6171 261 975400Two hundred sixty-one steps, a peak near a million — from a four-digit start. The table format holds; the walk really is that strange.
2. Take the file away. Rename starts.txt and re-run:
starts.txt is not here — the walk needs its starting pointsPart 6’s arrangement, doing its quiet work. Rename it back.
The map
The numbered path ends here; the themed tutorials each take one subject to the bottom. This is the reading order the series recommends when you want a particular thing:
| When you want | Read |
|---|---|
| the record from this page, properly — plus arrays, matrices, chosen bounds | Records, arrays, and bounds you choose, then the rest of Values and data |
case and for over domains you name — enumerations, characters, ranges | Ordinals: values that have a position |
sharing done deliberately — the full story behind address and value | Values, and arrows drawn by hand |
text beyond WriteLn — the builder, the window, runes in any script | the Strings section, starting at Text |
| files beyond line counting — typed transfers, paths, directories | the Files section, starting at Files |
| the failure channel in full — all four clauses, domains, walls, the C boundary | The failure channel, then Error domains |
| memory: the heap as obligations the compiler tracks, arenas, ownership | the Memory section, starting at Memory classes |
| one algorithm over many types, and programs grown past one file | Generics and Units and libraries |
| concurrency where a data race does not compile | the Concurrency section, starting at Tasks and the task tree |
| calling C, being called by C, calling the kernel — and debugging across it | the Boundary section, starting at Mica calls C |
| a whole compiler, built in Mica, taken apart chapter by chapter | Build a compiler with Mica |
Wherever you go next: every example lives in the tutorial repository, in learning order, each with a header that says what it teaches. And if the path left a gap the map does not cover, tell us: info@mica-dev.com.