~:~:0`!#@_-!!*>:#>#,__$
~: Read input char a and dup
~ Read input char b (-1 on EOF)
:0`! Push 1 if b > 0, 0 otherwise
#@_ Halt if b <= 0 (i.e. EOF)
-!! Check Subtract to check whether a != b
>#,_$ * Output a if so
The last part makes use of the fact that popping from an empty Befunge-93 stack yields 0.
If a != b
, we perform
> Multiply a by the result Move rightward
# > Bridge:# skip next
_ Horizontal if - go right if 0, else left. But a != b, so we go left
, Output a
# Bridge: skip next
- Subtract (0 - 0 = 0)
_ If: ago >right since 0 is popped
># Go right and skip next
_ If: go right since 0 is popped
$ Pop top of stack, outputstack a.is now empty
The last part makes use of the fact that popping from an empty Befunge-93 stack yields 0Otherwise, which means that if a
is positive we go left at _
and execute , == b
for output the first time, but on the second pass we go right at _
since 0 if popped from the stack.perform:
> Move rightward
# Bridge: skip next
_ If: go right since a == b (i.e. a-b is 0)
$ Pop top of stack and discard, keeping stack empty