- Read the article A Conversation with Einstein's Brain by Douglas
R. Hofstadter, which was handed out in class.
- Read the article The Appeal of Parallel Distributed Processing
by McClelland, Rumelhart, and Hinton, which was handed out in class. This
article introduces neural network or connectionist models of
cognition. Our goal for the next two weeks will be to implement a couple of
neural network models of memory and learning based on some of the ideas
discussed in this paper.
- To do this, we will employ the technique of object-oriented
programming. The oop-intro.scm
code discussed in class outlines the basic approach we will use. Study this
code until you understand how it works (in particular, version 5 of
make-object).
- Assuming that we always store numbers in the objects created by
make-object, add a new method called get-sum that returns the
sum of the two numbers stored in an object, without changing their values. You
do not need to introduce any new internal variables for this. Your new version
of make-object should behave exactly as shown below:
(define obj (make-object 7 8))
((obj 'get-sum)) => 15
((obj 'get-sum)) => 15
- Add a method called get-both that returns both of the object
values in a list. For example:
(define obj (make-object 7 8))
((obj 'get-both)) => (7 8)
- Add a method called scale that takes a number n as input
and changes the object's values by multiplying each one by n. The
scale method itself should return the symbol ok. Your
objects should behave exactly as shown below:
(define obj (make-object 7 8))
((obj 'get-x)) => 7
((obj 'get-y)) => 8
((obj 'scale) 10) => ok
((obj 'get-x)) => 70
((obj 'get-y)) => 80
((obj 'scale) 2) => ok
((obj 'get-x)) => 140
((obj 'get-y)) => 160
- Add a method called equal? that takes another object as
input and returns true if both of the other object's values are equal to
the first object's values, or false otherwise. For example:
(define obj1 (make-object 7 8))
(define obj2 (make-object 7 2))
(define obj3 (make-object 7 8))
((obj1 'equal?) obj2) => #f
((obj1 'equal?) obj3) => #t
Hint: you will need to use the methods get-x and get-y (or
else get-both) in order to extract the values from the other object
for comparison.