main_solution5/bf.scala
changeset 429 126d0e47ac85
parent 424 daf561a83ba6
child 430 274c865b3878
equal deleted inserted replaced
428:cdfa6a293453 429:126d0e47ac85
   109 }
   109 }
   110 
   110 
   111 def run(prog: String, m: Mem = Map()) = compute(prog, 0, 0, m)
   111 def run(prog: String, m: Mem = Map()) = compute(prog, 0, 0, m)
   112 
   112 
   113 
   113 
   114 
   114 def generate(msg: List[Char]) : String = msg match {
       
   115   case Nil => ""
       
   116   case c::cs => s"${"+" * c.toInt}.[-]" ++ generate(cs) 
       
   117 }
       
   118 
       
   119 //println(generate("Hello World\n".toList))
   115 
   120 
   116 
   121 
   117 // some sample bf/bf++-programs collected from the Internet
   122 // some sample bf/bf++-programs collected from the Internet
   118 //==========================================================
   123 //==========================================================
   119 
   124 
   210 
   215 
   211 }
   216 }
   212 
   217 
   213 
   218 
   214 //M5a.run(M5a.load_bff("mandelbrot.bf"))
   219 //M5a.run(M5a.load_bff("mandelbrot.bf"))
   215 M5a.run(M5a.load_bff("collatz.bf"))
   220 //M5a.run(M5a.load_bff("collatz.bf"))
       
   221 
       
   222 println(M5a.generate("ABC".toList))
       
   223 M5a.run(M5a.generate("Hello World\n".toList))