# Replace - avram - a virtual machine code interpreter
avram - a virtual machine code interpreter

### B.3 Replace

This code is needed in the discussion of assignment in Assignment. where it serves as a solution to equation E0. The idea is that the function takes an argument of the form `((`locations`,`values`),`store`)` and returns the store with the values stored at the locations indicated.

         locations = compose(left,compose(left,argument))
         values    = compose(right,compose(left,argument))
         store     = compose(right,argument)

         replace =

         refer conditional(
            store,
            (
               conditional(
                  compose(left,locations),
                  (
                     conditional(
                        compose(right,locations),
                        (
                           (hired meta)(
                              self,
                              couple(
                                 (hired fan right)(locations,values),
                                 (hired meta)(
                                    self,
                                    couple(
                                       (hired fan left)(locations,values),
                                       store)))),
                           couple(
                              (hired meta)(
                                 self,
                                 couple(
                                    couple(compose(left,locations),values),
                                    compose(left,store))),
                              compose(right,store)))),
                     conditional(
                        compose(right,locations),
                        (
                           couple(
                              compose(left,store),
                              (hired meta)(
                                 self,
                                 couple(
                                    couple(compose(right,locations),values),
                                    compose(right,store)))),
                           values)))),
                  (hired meta)(
                     self,
                     couple(couple(locations,values),constant (nil,nil)))))