Try it online!
Outputs nothing (which is falsy in Ordinal mode) or
Jabberwocky (which is non-empty and therefore truthy in Ordinal mode; it's also the canonical truthy string value).
This is a slight modification of the general framework for linear Ordinal mode programs. The
/ in the middle is used to have a single operator in Cardinal mode in between (the
*) and then we need the
# to skip it in Ordinal mode on the way back. The linear program is then:
Let's go through that:
i Read all input as a string and push it to the stack.
.. Make two copies.
* This is run in Cardinal mode, so it implicitly converts the top two
copies to their integer value and multiplies them to compute the square.
. Implicitly convert the square back to a string and make a copy of it.
Q Reverse the stack to bring the input on top of the two copies of its square.
L Shortest common supersequence. This pops the input and the square from
the top of the stack and pushes the shortest string which begins with
the square and ends with the input. Iff the square already ends with the
input, this gives us the square, otherwise it gives us some longer string.
z Drop. Pop the SCS and the square. If the square contains the SCS (which
would mean they're equal), this removes everything up to the SCS from
the square. In other words, if the SCS computation left the square
unchanged, this gives us an empty string. Otherwise, it gives us back
n Logical not. Turns the empty string into "Jabberwocky" and everything
else into an empty string.
o Print the result.
@ Terminate the program.