main_templates5/bf.scala
changeset 428 cdfa6a293453
parent 400 e48ea8300b2d
child 429 126d0e47ac85
--- a/main_templates5/bf.scala	Sat Oct 08 00:30:51 2022 +0100
+++ b/main_templates5/bf.scala	Tue Nov 01 15:03:48 2022 +0000
@@ -5,45 +5,26 @@
 
 object M5a {
 
-
 // representation of BF memory 
 
 type Mem = Map[Int, Int]
 
-
-// (1) Write a function that takes a file name as argument and
-// and requests the corresponding file from disk. It returns the
-// content of the file as a String. If the file does not exists,
-// the function should return the empty string.
-
 import io.Source
 import scala.util._
 
+// ADD YOUR CODE BELOW
+//======================
+
+// (1)
 def load_bff(name: String) : String = ???
 
-
-
-// (2) Complete the functions for safely reading  
-// and writing brainf*** memory. Safely read should
-// Return the value stored in the Map for a given memory
-// pointer, provided it exists; otherwise it Returns 0. The
-// writing function generates a new Map with the
-// same data, except at the given memory pointer the
-// value v is stored.
-
+// (2) 
 
 def sread(mem: Mem, mp: Int) : Int = ???
 
 def write(mem: Mem, mp: Int, v: Int) : Mem = ???
 
-
-
-// (3) Implement the two jumping instructions in the 
-// brainf*** language. In jumpRight, given a program and 
-// a program counter move the program counter to the right 
-// until after the *matching* ]-command. Similarly, 
-// jumpLeft implements the move to the left to just after
-// the *matching* [-command.
+// (3) 
 
 def jumpRight(prog: String, pc: Int, level: Int) : Int = ???
 
@@ -60,21 +41,7 @@
 
 
 
-// (4) Complete the compute function that interprets (runs) a brainf***
-// program: the arguments are a program (represented as a string), a program 
-// counter, a memory counter and a brainf*** memory. It Returns the
-// memory at the stage when the execution of the brainf*** program
-// finishes. The interpretation finishes once the program counter
-// pc is pointing to something outside the program string.
-// If the pc points to a character inside the program, the pc, 
-// memory pointer and memory need to be updated according to 
-// rules of the brainf*** language. Then, recursively, the compute 
-// function continues with the command at the new program
-// counter. 
-//
-// Implement the run function that calls compute with the program
-// counter and memory counter set to 0.
-
+// (4) 
 
 def compute(prog: String, pc: Int, mp: Int, mem: Mem) : Mem = ???