106 |
106 |
107 def run(prog: String, m: Mem = Map()) = compute(prog, 0, 0, m) |
107 def run(prog: String, m: Mem = Map()) = compute(prog, 0, 0, m) |
108 |
108 |
109 |
109 |
110 |
110 |
111 /* |
111 |
112 |
112 |
113 // some sample bf-programs collected from the Internet |
113 // some sample bf-programs collected from the Internet |
114 //===================================================== |
114 //===================================================== |
115 |
115 |
116 |
116 |
200 <]]++++++[>+++++++<-]>++.------------.[-]>[>>]<<[+++++[>+++++ |
200 <]]++++++[>+++++++<-]>++.------------.[-]>[>>]<<[+++++[>+++++ |
201 +++<-]>.<++++++[>--------<-]+<<]+<]>[<+>-]<]>>>[>>]<<[>[-]<-< |
201 +++<-]>.<++++++[>--------<-]+<<]+<]>[<+>-]<]>>>[>>]<<[>[-]<-< |
202 <]++++++++++.[-]<<<[<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<+>-[<+>- |
202 <]++++++++++.[-]<<<[<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<+>-[<+>- |
203 [<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-]]]]]]]]]]<[>+<-]+>>]<<[<<]>>]""") |
203 [<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-]]]]]]]]]]<[>+<-]+>>]<<[<<]>>]""") |
204 |
204 |
|
205 // 2 to the power of 6 |
|
206 //(example from a C-to-BF compiler at https://github.com/elikaski/BF-it) |
|
207 run(""">>[-]>[-]++>[-]++++++><<<>>>>[-]+><>[-]<<[-]>[>+<<+>-]>[<+>-] |
|
208 <><[-]>[-]<<<[>>+>+<<<-]>>>[<<<+>>>-][-]><<>>[-]>[-]<<<[>>[-] |
|
209 <[>+>+<<-]>[<+>-]+>[[-]<-<->>]<<<-]>>[<<+>>-]<<[[-]>[-]<<[>+> |
|
210 +<<-]>>[<<+>>-][-]>[-]<<<<<[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-] |
|
211 <<>>[-]>[-]<<<[>>>+<<<-]>>>[<<[<+>>+<-]>[<+>-]>-]<<<>[-]<<[-] |
|
212 >[>+<<+>-]>[<+>-]<><[-]>[-]<<<[>>+>+<<<-]>>>-[<<<+>>>-]<[-]>[-] |
|
213 <<<[>>+>+<<<-]>>>[<<<+>>>-][-]><<>>[-]>[-]<<<[>>[-]<[>+>+<<-]> |
|
214 [<+>-]+>[[-]<-<->>]<<<-]>>[<<+>>-]<<][-]>[-]<<[>+>+<<-]>>[<<+> |
|
215 >-]<<<<<[-]>>>>[<<<<+>>>>-]<<<<><>[-]<<[-]>[>+<<+>-]>[<+>-]<> |
|
216 <[-]>[-]>[-]<<<[>>+>+<<<-]>>>[<<<+>>>-]<<>>[-]>[-]>[-]>[-]>[-]> |
|
217 [-]>[-]>[-]>[-]>[-]<<<<<<<<<<>>++++++++++<<[->+>-[>+>>]>[+[-<+ |
|
218 >]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<< |
|
219 ]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++ |
|
220 ++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]<<><<<""") |
|
221 |
205 |
222 |
206 |
223 |
207 // a Mandelbrot set generator in brainf*** written by Erik Bosman |
224 // a Mandelbrot set generator in brainf*** written by Erik Bosman |
208 // (http://esoteric.sange.fi/brainfuck/utils/mandelbrot/) |
225 // (http://esoteric.sange.fi/brainfuck/utils/mandelbrot/) |
209 |
226 |