Execute Brain****/Standard ML: Difference between revisions
Content added Content deleted
m (moved RCBF/Standard ML to Execute Brain****/Standard ML) |
m (Fixed syntax highlighting.) |
||
Line 10: | Line 10: | ||
A more efficient implementation could for example only admit well-bracketed brainfuck programs, and parse bracket blocks first, to replace the ''matchLeft'' and ''matchRight'' which need linear time. |
A more efficient implementation could for example only admit well-bracketed brainfuck programs, and parse bracket blocks first, to replace the ''matchLeft'' and ''matchRight'' which need linear time. |
||
< |
<syntaxhighlight lang="sml">fun moveLeft (x::l, r) = (l, x::r) |
||
fun moveRight (l, x::r) = (x::l, r) |
fun moveRight (l, x::r) = (x::l, r) |
||
Line 43: | Line 43: | ||
| exec (p as (_, #"]"::_), d ) = exec (matchLeft (moveLeft p), d) |
| exec (p as (_, #"]"::_), d ) = exec (matchLeft (moveLeft p), d) |
||
fun run s = exec (([], s), ([0], [0]))</ |
fun run s = exec (([], s), ([0], [0]))</syntaxhighlight> |
||
Example output: |
Example output: |