[]{<{}{}>}{}
Run example
$ printf "0 0" | ./flurry -nib -c "[]{<{}{}>}{}" 73728 $ printf "0 1" | ./flurry -nib -c "[]{<{}{}>}{}" 75264 $ printf "0 11" | ./flurry -nib -c "[]{<{}{}>}{}" 3687936
Takes two numbers separated by single space from stdin in binary mode, and prints the return value as an integer.
The binary mode is the trick here. What the program does is to implicitly push all codepoints of stdin to the stack, and print the product of the entire stack.
Code explanation
// Pop (stack height + 1) times and compute the product; // popping from empty stack gives I = 1 // [] {<{}{}>} {} main = height times-pop pop // { <{} {} >} times-pop = \x. x ∘ pop
Proof that this does not give a+b for any a b
Base case: The input of "0 0" gives 48 × 32 × 48 = 73728.
Inductive case:
- The codepoint of any printable ASCII is 32 or above, so adding a digit (which amplifies
a+b by at most 10) amplifies the output by 32 or above. - Adding 1 to an existing digit adds the product of all the codepoints except itself to the output, which is much greater than the digit value of the modified digit.
Therefore, the output grows much faster than the value of a+b, and they can never be equal.
For comparison, here is the program that computes a+b+1:
{}(<><<>()>)[{}{}]
$ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 12 13 26 $ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 0 0 1 $ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 0 10 11
// initial stack = a b // {} (<><<>()>) [{} {} ] main = pop (push succ) (pop pop) // b succ a = b succ (succ a) = b + succ a = a + b + 1