Do you know that language?
1. Retina, 0 bytes
Try it online!
The empty program prints 1
when given empty input (i.e. itself), because it counts how often the empty regex matches the input (which is always 1+length(input)
).
2. Brain-Flak, 22 bytes
{<>(())(<>)}{}(<>{}())
Try it online!
This checks the top of the stack and puts a one on the opposite stack if it is non-zero. It then increments and returns the opposite stack. This makes it return 1 for the empty program and 2 for anything else.
Since stacks in Brain-Flak default to zero, an empty program will have a zero on the top of the stack while any other program (except programs which end in null characters) will have a truthy value. This means we can run a very simple if program on the input stack.
{ (<>)}{} #If not zero
<>(()) #Push one to the other stack
(<>{}()) #Switch to other stack and increment by one
3. APL, 7 bytes
' {'⍳⊃⍞
Explanation:
⍞ read from the keyboard
⊃ first item of list, or space if empty
' {'⍳ index into the string ' {', giving N+1 (=3) if not found