Execute Brain****/Haskell: Difference between revisions

m
<lang>
m (<code>)
m (<lang>)
Line 8:
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.
 
<codelang haskell>moveLeft (x:l,r) = (l,x:r)
moveRight (l,x:r) = (x:l,r)
 
Line 43:
 
dialog :: String -> IO ()
dialog s = mapM_ print . run s . map read . lines =<< getContents</code>
</lang>
 
Example session:
 
<pre>
<pre>: *Main> dialog ",[>+<-].>."
: ''5''
: 0
: 5</pre>
</pre>
973

edits