// echo — record & replay with lists
//
// Record a noisy walk, then re-sew it mirrored, echoed in shuffled
// palette colours — a tour of the list features (RFC-2):
// literals, append/pos recording, for-in, indexing, setpos,
// and the seeded shuffle randomness.

// --- walk ---
let nsteps    = 70   // [10:200] steps in the recorded walk
let stepsize  = 1.6  // [0.5:0.2:4] step length, mm
let echospace = 2.5  // [0.5:0.5:8] horizontal drift per echo, mm

seed 5
let thread_slots = [2, 3, 5, 7]
let path = []

up setxy(-26, 24) down
repeat nsteps [
  seth(noise2(xcor / 8, ycor / 8) * 360)
  fd stepsize
  append(path, pos())
]
trim

let off = 0
// `shuffle` changes the colour order; the seed above makes that order repeatable.
for c in shuffle(thread_slots) [
  color c
  // Negating x mirrors the recorded path; `off` separates each echo.
  up setpos([-first(path)[0] + off, first(path)[1]]) down
  for p in path [
    setpos([-p[0] + off, p[1]])
  ]
  trim
  off += echospace
]
print "points" len(path)
