
joeyh at
Charles Stanhope likes this.
Show all 5 replies



helloworld :: String helloworld = brainfuck $ forM_ "hello, world!" $ flip withChar output
Generates a page of brainfuck.. which does print out the greeting when run.

-- | Optimized to use less space. helloworld' :: String helloworld' = brainfuck $ go 0 $ map Char.ord "hello, world!" where go n [] = return () go n (c:cs) = do let delta = c - n multi (if delta > 0 then incr else decr) (abs delta) output go c cs
I think this generates the shortest possible brainfuck hello world program. And I wrote it in ... 15 minutes?

So yeah, I have a function that can optimize brainfuck code. For example, converts ">[-]>[-]+[<>[-],.<>]<<" to "+[[-],.]"
Christopher Allan Webber likes this.