I have a sequence, starting with $1$. You store the current sequence as a list, then duplicate it. In this copy, you invert it, turning $1$s into $0$s, and $0$s into $1$s. Then, you join it on to the first sequence.* So it goes:
$$1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1...$$
Using this, how do you get a function taking the input $n$, and outputting the $n$-th element of this sequence, without calculating every element up to that one?
I've used the recursive program for generating a square grid of these, as white and black squares, but want to use my line-based fractal generator instead. But for my purposes, I need a function that can calculate any element without knowing the ones before it.
*The function actually scans through the existing list, adding elements, to be more efficient, but this explanation's more intuitive.