solutions5/bf.scala
changeset 244 0ab369f53ac1
parent 231 26b5a843c696
child 264 25f3fbc43251
equal deleted inserted replaced
243:80102fba0a93 244:0ab369f53ac1
   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