in Haskell you can read off the generating function's coefficients directly from the functional equation T(z) = z + zT + zT² + zT²<p>ghci> ts=0:(1+ts+ts^2+ts^3)
ghci> take 12 ts
[0,1,1,2,5,13,36,104,309,939,2905,9118]<p>Using the Num instance for power series (very cute application of laziness expounded by Karczmarczuk and then McIlroy <a href="https://dl.acm.org/doi/abs/10.1017/s0956796899003299" rel="nofollow">https://dl.acm.org/doi/abs/10.1017/s0956796899003299</a>)