19 17 bytes non-competing
New version (17 bytes):
This new version takes the characters one at a time and is best executed with the
-F option. It works similar, but not identical to the previous solution:
Old answer (19 bytes):
(Non-competing because I had to fix two bugs in the interpreter)
This is the first Aceto answer that highlights what it can do relatively well, I would say. The "lists" are input streams, with one input per line, "1" for true, and "0" for false, with an empty string signifying the end of the list.
Aceto programs run on a Hilbert curve, starting on the bottom left, and ending on the bottom right. First, we
read a string,
duplicate, and negate (
!) it, turning empty strings into True, everything else into False. Then there's a conditional horizontal mirror (
|): If the top element on the stack is truthy, mirror horizontally. This happens when the string was empty. If we do the mirroring, we land on the
X, which kills the interpreter.
Otherwise, we convert the remaining copy on the stack to an
integer and do another conditional horizontal mirror: This time, because 1 is truthy and 0 is falsy, we mirror if we see the (first) true value. If we don't mirror (so we saw a 0) we
print what's on the stack (since the stack is empty, a zero) and jump to the
Origin of the curve, where we started, starting the whole process again.
Otherwise, when we saw a 1, we mirror and land on the
u, which reverses the direction we move on the Hilbert curve.
1p prints a 1, and now we go on the same
O we would have gone if we had seen a 0, but since we're in "reversed mode", our origin is at the bottom right, so we jump there.
read another string, and negate it. If the string was empty, and therefore the top stack element is truthy,
` will not escape the next command (
X), making us quit.
Otherwise (if the string wasn't empty), we do escape the
X and ignore it. In that case, we go to the left (
print 0 (because the stack is empty), and jump back to the