Skip to content

Instantly share code, notes, and snippets.

@sordina
Created July 7, 2016 00:22
Show Gist options
  • Save sordina/3c1f4dcb7c1d687943a963a3a090c352 to your computer and use it in GitHub Desktop.
Save sordina/3c1f4dcb7c1d687943a963a3a090c352 to your computer and use it in GitHub Desktop.
main = putStrLn prelude
>> interact (unlines . filter (not . null) . map compile)
>> putStrLn afterward
a +++ b = a ++ "\n" ++ b
prelude = "#include <stdio.h>"
+++ "char b[1000000];"
+++ "int main() {"
+++ "char* p = b;"
compile '>' = "p++;"
compile '<' = "p--;"
compile '[' = "while (*p) {"
compile ']' = "}"
compile ',' = "(*p) = getchar(); if (*p == EOF) { return 0; }"
compile '.' = "putchar(*p);"
compile '+' = "(*p)++;"
compile '-' = "(*p)--;"
compile _ = ""
afterward = "}"
+++ "// lol"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment