~nasser/8fl

88db9fbd60ad2797c72f85f4e63c38936cc99f82 — Ramsey Nasser 2 months ago 8af6c78
Clean up product implementation
1 files changed, 1 insertions(+), 9 deletions(-)

M patterns.fnl
M patterns.fnl => patterns.fnl +1 -9
@@ 99,18 99,10 @@
      (each [s (seq.iter _seq)]
        (coroutine.yield s)))))

(fn split [x]
  (string.gmatch x "."))

(fn maybe-split [x]
  (match (type x)
    :string (split x)
    _ x))

(fn product [xs rhs]
  (let [xs (seq.cycle xs)]
    (resumable
      (each [r (seq.iter (maybe-split rhs))]
      (each [r (seq.iter (seq.iter rhs))]
        (if (core.rest? r)
          (coroutine.yield r)
          (coroutine.yield (xs)))))))