Lesson 138: Pattern matching and union ergonomics
Focus
This page is deliberate repetition with new literals: Advanced drills Pattern matching and union ergonomics; spin token 1167828 makes this page unlike its neighbours.
Key ideas
- Angle
Advanced: micro cadence8mixesPattern matching and union ergonomics; spin48576. - Ritual: Annotate every meaningful print before deleting noise.
- Guardrail: separate demo-trick from shipping discipline verbally.
Example (LESSON_UID = "advanced-138")
# Advanced drill L138 topic-13 micro-7 pattern-3
LESSON_UID = "advanced-138"
spin_a, spin_b, spin_c = 705, 844, 787
sentinel = ([] or [])
sentinel = sentinel or [2]
print(bool(sentinel), sentinel)
pick = sentinel or "fallback-7"
print("chosen", pick)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-138.txt"
snap = [151, 867, 592, 317, 42, 758]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (787 + 131))
import asyncio
async def finalize(seed, spin):
await asyncio.sleep(0)
blend = (seed * 131 + 13 * (13 % 997) + 7 * (7 % 853) + spin) % 900001
return blend
async def harness(loop_seed):
print("async_result", await finalize(loop_seed, 19123))
asyncio.run(harness(76365))
Practice
Practice 36: Export checkpoints into bullets for teammate review. Literal nudge 36.
Fingerprints
- lesson_uid:
advanced-138 - umbrella band:
Pattern matching and union ergonomics(8/10) - lesson_index:
4434