Insomnia

From Esolang
Jump to: navigation, search

Insomnia is a language by User:fr34k and is based on the ASCII character encoding.


Workflow

Insomnia syntax consists solely of ASCII characters. This entire page could, for example, be an Insomnia program. However, what operates are the characters ASCII values. For instance, if a program would look like this:

W

Insomnia would read this as

87

Logical, since the decimal representation of W is 87. Now, what happens next is that commands number 8 and 7 will be executed. This workflow makes it almost impossible coding something intended in Insomnia. (Not for long, see Notes).

When coding in Insomnia, one has an unlimited (as many as needed) groups consisting of 8 bits, with a pointer starting at the left-most bit in one group.

Commands

0 - Flip current bit and move pointer right
1 - Flip current bit and move pointer left
2 - Flip current bit
3 - Move pointer right to next group
4 - Move pointer left to previous group
5 - Output block as digit
6 - Output block as letter
7 - NOP
8 - While target of pointer is not 0
9 - End while

Example programs

"Hello, world!"

A hello world program in Insomnia won't output 'Hello, world!' (theoretically, it would be almost impossible) though it consists more of a hello world syntax. The program would look like this:

Hello, world!

The ASCII equivalent would be

72101108108111443211911111410810033

This program would do the following, in order

  • NOP
  • Flip current bit
  • Flip current bit and move pointer left
  • Flip current bit and move pointer right

And so on...

If we would picture the current bit-groups as of now, it would look something like this

00000001
^

This is because when moving the pointer out of boundaries of a group, the pointer returns to the opposite side of the group. That is, when you begin like this:

00000000
^

And move the pointer to the left, you would get this

00000000
       ^

And when moving the pointer to another group, the pointer will always position itself to the left-most bit.


"Cat"

A cat program would, like Hello, world!, look like this

CAT

or

676584

And would do the following

  • Output block as letter
  • NOP
  • Output block as letter
  • Output block as digit
  • While pointer is not zero
  • Move pointer left to previous group

This program would output

0

Because of the 5 command, which output the block as digit. Since the block hasn't been changed it stayed 0. However, this program will fail, because of the command 8. This is a start of a while command, but no end is specified.

Notes

Since Keymaker pointed out that one could use F, G, H, I, J, K, L, M, N, and O to program (since their ASCII values range from 70 to 79) Insomnia 2.0 has been developed, solely to make it closer to impossible to program in Insomnia. However, Insomnia 2.0 has a simlar weakness involving extended ascii characters. Ü, Ý, Þ, ß, à, á, â, ã, ä, å all flip the current bit twice then do what you want.

The reason for using F, G, H, I, J, K, L, M, N, and O are because their ASCII values range from 70 to 79, meaning every letter makes a NOP and then whatever you intended it to do.