# SICP Solutions

### Chapter 4, Metalinguistic Abstraction

#### Exercise 4.12

That’s interesting.

Note: I implemented it on top of previous exercise.

I think the way book has given the code, it seemed that they already hinted that we traverse in environment and frame to find the correct pair.

So, implementing a generic find is the way to go!

find excepts 3 arguments:

• contains?: when an element is passed it checks whether that element contains the required “thing”! If found, it returns that “thing” or returns false.
• next: thats to go to the next element - in our case we need this to go to next environment, or next pair.
• data

Now, an interesting happened! I realised that assoc can be implemented using find! So, need not to use mit scheme’s version or ch-3 code for assoc

find-pair, implemented using find again, returns the pair that contains the variable else returns false.

Output:

Well, I tried few examples from previous exercise that involves creation of variables, lambdas…