We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Skewedbrain

From Esolang
Jump to navigation Jump to search

Skewedbrain is an esolang invented by User:None1. It's brainfuck except that the instructions are unbalanced.

Logo for Skewedbrain
Logo for Skewedbrain

Memory

Like brainfuck, Skewedbrain uses an infinitely long tape with wrapping byte cells.

Commands

Command Meaning
+ Add current cell by 3.
- Subtract current cell by 5.
> Move the pointer 2 cells to the right.
< Move the pointer 7 cells to the left.
, Input a byte, add it by 11, and store it in current cell.
. Output current cell plus 13 modulo 256 as an ASCII character.
[ If current cell is 1, jump past the matching ]
] If current cell isn't 2, jump past its leftmost matching [

Bracket matching

In Skewedbrain, every ] matches two ['s, for example, in:

[[[[]]

The first ] matches the third and the fourth ['s, while the second ] matches the first and the second ['s.

Examples

Programming in this language is very confusing and challenging because of the ‌imbalance.

Cat program (never terminates)

[>>>[>>>>,------++.<<]

Hello, world!

Unoptimized. Replace if you have a shorter one.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.>
----------------------------------------------------------------------------------------------------------------------------------------.>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.>
--------------------------------------------------------------------------------------------------------------------------------------.>
---------------------------------------------.>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.>
------------------------------.>
--------------------------------------------------------------------------------------------------------------------------------------.>
-------------------------------.>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.>
-------------------------------------------------------------------------------------.>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.

Truth machine

,------++.--------++[>>>>>>>++++++++++++[.---------+++<<[[-]]

Interpreter

Python

import sys
def skb(code):
    s=[]
    matches={}
    tape=[0]*1000000
    for i,j in enumerate(code):
        if j=='[':
            s.append(i)
        if j==']':
            matches[s.pop()]=i
            m=s.pop()
            matches[m]=i
            matches[i]=m
    cp=0
    p=0
    while cp<len(code):
        if code[cp]=='+':
            tape[p]=(tape[p]+3)%256
        elif code[cp]=='-':
            tape[p]=(tape[p]-5)%256
        elif code[cp]==',':
            c=sys.stdin.read(1)
            tape[p]=((ord(c) if c else 0)+11)%256
        elif code[cp]=='.':
            print(chr((tape[p]+13)%256),end='',flush=True)
        elif code[cp]=='<':
            p-=7
        elif code[cp]=='>':
            p+=2
        elif code[cp]=='[':
            if tape[p]==1:
                cp=matches[cp]
        elif code[cp]==']':
            if tape[p]!=2:
                cp=matches[cp]
        cp+=1
skb(sys.stdin.read())

Turing-completeness

The author had a Turing-completeness proof, but it's too long to fit in the margin.