Dupdog

From Esolang
Jump to navigation Jump to search

Dupdog is a thing made by Seven Inch Bread that looks like a self-modifying esoteric language.

Specification

A dupdog program consists of a series of arbitrary characters read by two alternating interpreters named mfit and shanty, each performing different actions for different characters. The first character is read by mfit, removed from the source, and an action performed. The new first character is read by shanty, removed from the source, and an action performed. This repeats until there are no more characters to read or until something in the source causes the program to exit.

Mfit

Mfit (pronounced "Miff it") understands the following characters:

~ duplicate the source code

? if the length of the source is even, transform all ?'s to !, all !'s to  ~, and all ~'s to          
  ?. if odd, do nothing.

If the character is something else, the length of the source code (including the current character) is calculated, converted to an ASCII character, and written to standard output. An optional wrap-around can be implemented by the interpreter for this - but the exact value at which to wrap is left undefined.

Shanty

Shanty understands the following characters:

!  duplicate the source code
 
?  reverse the source code

If the character is something else, the length of the current source (including the currently read character) is calculated and written to standard output as its decimal representation, and the program stops.

Examples

Hello, World! Program

Thanks to Nikita Ayzikovsky (a.k.a user:lament) for having the attention span to make this. This program assumes that the character set wraps mod 257 (in a character set wrapping mod 256 or 128, the Hello, world! program is still believed to be possible, but is considerably more difficult to write).

H?????????????????????????????????????????????????????????????????????????????????????????????????????????????????e?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????l???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????w???o?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????l???d?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????r???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????X???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????o???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????l??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Infinite Loop

~?~

Mfit duplicates ?~ so the code is now ?~?~. Shanty then reverses ~?~ which is ~?~ again, so you have an infinite loop.

External resources