• 7heo@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        9 months ago

        Brainfuck, but with parentheses only.

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

        Hello world example:

        ()))(((()(())))(())(())))))()))))(()
        (()(()(()(()(((((())(((((()(()((((()
        (()(()))()))(()()()))))))))())()()))
        )))()(()(())())()))((()()))))(((((((
        ((((((()(())())())()((()(()(()(()(()
        (()()((((((((()()())))))))))))())()(
        

        8fga6t_051712

        Python transpiler:

        #!/usr/bin/env python
        
        from sys import stdin
        
        OPS = { ")))": '>', "(((": '<', "())": '+', "(()": '-',
                "()(": '.', ")()": ',', ")((": '[', "))(": ']' }
        
        def main():
          _d = ''.join(stdin.readlines()).rstrip('\n')
          for _op in [_d[x:x+3] for x in range(0, int(len(_d)), 3)]:
            print(OPS[_op], end='')
        
        if __name__ == "__main__":
          main()