Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 753 Bytes

catalan.md

File metadata and controls

25 lines (16 loc) · 753 Bytes

Catalan numbers

Power series, power serious introduces Catalan numbers via solving the generating function equation $T = 1 + x T^2$.

This equation can be translated to the circuit.

catalan-1

step-1

catalan-2

(define catalan
  (~>> (one)
       (c-loop (~>> (== _ (c-reg 0))
                    (c-add +)
                    (-< _ (~>> (-< _ _) c-convo))))
       ))
(probe (~>> (catalan) (stream-take _ 10) stream->list))
;; '(1 1 2 5 14 42 132 429 1430 4862)