Lesson 132: Pattern matching and union ergonomics
Focus
Slow tempo wins; narrate checkpoints aloud: Advanced drills Pattern matching and union ergonomics; spin token 1093961 makes this page unlike its neighbours.
Key ideas
- Angle
Advanced: micro cadence2mixesPattern matching and union ergonomics; spin55924. - Ritual: Annotate every meaningful print before deleting noise.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "advanced-132")
# Advanced drill L132 topic-13 micro-1 pattern-11
LESSON_UID = "advanced-132"
spin_a, spin_b, spin_c = 640, 559, 101
bucket = dict(seed=1 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(5), tweak(2), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-132.txt"
snap = [145, 790, 444, 98]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (101 + 131))
import asyncio
async def finalize(seed, spin):
await asyncio.sleep(0)
blend = (seed * 131 + 13 * (13 % 997) + 1 * (1 % 853) + spin) % 900001
return blend
async def harness(loop_seed):
print("async_result", await finalize(loop_seed, 77401))
asyncio.run(harness(16449))
Practice
Practice 23: Shadow one variable purposely to spotlight scope quirks. Literal nudge 23.
Fingerprints
- lesson_uid:
advanced-132 - umbrella band:
Pattern matching and union ergonomics(2/10) - lesson_index:
4200