User:Jan jelo/a BF interpreter in Uiua

From Esolang
Jump to navigation Jump to search

This is a Brainfuck interpreter in Uiua written by User:Jan jelo.

P ← ⍣(
  0°@+
| 1°@-
| 2°@<
| 3°@>
| 4°@[
| 5°@]
| 6°@.
| 7°@,
| 8
)
Init ← {
  "\0" "\0"
  0
}
Lt  ← ⊡0
Rt  ← ⊡1
Pc  ← ⊡2
Pg  ← ⊡3
Op  ← ⊡∩°□:Pg:Pc∘.
Cur ← ⊣°□Lt
Th  ← ⍜(Pc|□+°□):
I   ← Th1⍜(Lt|□⊂↙-1⧻.:⨬(+1|@\0◌)=@\xff.⊣.°□)
D   ← Th1⍜(Lt|□⊂↙-1⧻.:⨬(-1|@\xff◌)=@\x00.⊣.°□)
L   ← Th1⍜(Rt|□⊂°□)⍜(Lt|□⨬(∘|↙-1⧻.)>1⧻.°□):⊣°□Lt.
R   ← Th1⍜(Lt|□⊂°□)⍜(Rt|□⨬(∘|↙-1⧻.)>1⧻.°□):⊣°□Rt.
In  ← Th1⍜(Lt|□⊂↙-1⧻.:⨬(∘|@\n◌)=0⧻.&sc°□)
Out ← Th1&pf⊣°□Lt.

FindL ← °□⊣⍢(
  ⨬(⨬(∘
    | ⍜(⊢|□-1°□)
    )=5°□Op°□⊣.
  | ⍜(⊢|□+1°□)
  )=4°□Op°□⊣.⍜(⊣|□Th 1°□)
| ≠0°□⊢
)
Lb ← ⨬(
  ⍜(Pc|□+1°□)
| FindL⊂{1}□
)=@\0Cur.
FindR ← °□⊣⍢(
  ⨬(⨬(∘
    | ⍜(⊢|□-1°□)
    )=5°□Op°□⊣.
  | ⍜(⊢|□+1°□)
  )=4°□Op°□⊣.⍜(⊣|□Th¯ 1°□)
| ≠0°□⊢
)
Rb ← ⨬(
  ⍜(Pc|□+1°□)
| FindR⊂{¯1}□
)≠@\0Cur.
Run ← ◌⍢(
  ⨬(I
  | D
  | L
  | R
  | Lb
  | Rb
  | Out
  | In
  | Th 1
  )Op. # &pf.&pf @\n
| ≠°□Pc:⧻°□Pg.
)⊂Init□∵P
Run $ ++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++ ..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.
#Hello World!