Hyper Binary Sequence

The Hyper Binary Sequence were created by Polymations.Polymations Polymations' Googologisms - Functions. Retrieved 2024-03-04.
== Definition ==
A Hyper Binary Sequence is in the form <string>[n].
If the string is "0", return n+1.
If the string ends in "0", but isn't 0, return <string without 1>[<string without 1>[...n times...[n]...]]
If the string ends in "1", expand the string as follows:
If the string ends in "0", return the string.
Otherwise, if the string has only 1 zero in it (and it is at the beginning), return the string without the 1 concatenated to itself n times.
If none of the above are true, let the bad part be the last "0" of the string along with anything to the right of it and let the good part be everything that isn't the bad part. Now return the good part concatenated with the expanded form of the bad part.
=== Definition using Mathematical Symbols ===
\(\begin{multline}\text{let Quantity(A,n) represent the amount of n's in A,}\\\text{and let l(A) represent all but the last element of A,}\\\text{and let a}\smile\text{b represent the concatenation of a and b.}\\ \left\langle s \right\rangle[n]:\\ \begin{cases}n+1&s=\text{0}\\ \left\langle l(s)\right\rangle^n[n]&s[s\text{.length}-1]=0\\ \left\langle\text{expand}(s,n)\right\rangle[n]&\text{otherwise} \end{cases}\\ \text{expand}(s,n):\\ \begin{cases}s&s[s\text{.length}-1]=0\\ \underbrace{l(s)\smile \cdots\smile l(s)}_n&\text{Quantity}(s,1)=1\\ \text{good}(s)\smile \text{expand}(\text{bad}(s))&\text{Otherwise} \end{cases}\\ \text{good}(s)=s\text{.filter}(\text{index< last 1 in s})\\ \text{bad}(s)=s\text{.filter}(\text{index}\geq \text{last 1 in s})\end{multline}\)
== Sources ==