# [Haskell](https://www.haskell.org), 46 bytes ```haskell g _ 0=[] g(h:t)n=h:g(t++[sum$h:t])(n-1) ``` ``` g.g[1] ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ8GCpaUlaboWNw3SFeIVDGyjY7nSNTKsSjTzbDOs0jVKtLWji0tzVYAisZoaebqGmlxptul66dGGsVB9YbmJmXkKtgop-VwKCrmJBb4KBUWZeSVAjkK0QpqCsYIFiKkDZJorGBrD2IYKRgYwtrGBggmMbapgaAhiQ02HuQ4A) This is based on [xnor's answer](https://codegolf.stackexchange.com/a/70522/) but it employs 1 clever trick. The \$n\$-bonacci sequence always start with \$n\$ `1`s. A more general version of this might start with just any \$n\$ values. And this more general version is what we implement with `g`. `g` takes a list of \$n\$ integers and a value \$m\$ and gives us a list of the first \$m\$ terms of this generalized \$n\$-bonacci sequence. The trick is then that `g[1]` is a cheap way to generate \$n\$ `1`s. Since the sequence starting with `[1]` is just an endless stream of `1`s. So we use `g` in two ways, and even though `g` might be slightly longer because it implements something a little more general it saves bytes because it serves two purposes.