solutions5/bf.scala
changeset 244 a359976a6f3e
parent 231 eecbc9ae73c2
child 264 ecd989eee8bd
equal deleted inserted replaced
243:9bb36426c781 244:a359976a6f3e
   105 }
   105 }
   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 // some sample bf-programs collected from the Internet
   113 // some sample bf-programs collected from the Internet
   113 //=====================================================
   114 //=====================================================
   114 
   115 
   136 run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
   137 run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
   137        ..+++.>>.<-.<.+++.------.--------.>>+.>++.""")
   138        ..+++.>>.<-.<.+++.------.--------.>>+.>++.""")
   138 
   139 
   139 // hello world program 2
   140 // hello world program 2
   140 run("""++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>+
   141 run("""++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>+
   141       +.<<+++++++++++++++.>.+++.------.--------.>+.>.""")
   142        +.<<+++++++++++++++.>.+++.------.--------.>+.>.""")
   142 
   143 
   143 
   144 // hello world program 3
       
   145 run("""+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..
       
   146        +++.>-.------------.<++++++++.--------.+++.------.--------.>+.""")
       
   147 
       
   148  
   144 // draws the Sierpinski triangle
   149 // draws the Sierpinski triangle
   145 run("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
   150 run("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
   146       ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
   151       ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
   147       ]>.>+[>>]>+]""")
   152       ]>.>+[>>]>+]""")
   148 
   153