# SICP Solutions

### Chapter 4, Metalinguistic Abstraction

#### Exercise 4.50

I used dreaded assignment to move a random element at the beginning of the list and then using that as the next amb value.

Output:

#### Improvement in Alyssa’s approach

As noted in last exercise, we have to find some way so that the words generation do not keep going in infinite loop only in one branch of possibilities. This was happening because we keep adding new prepositions because of the way amb works.

Now, if we replace all the amb with ramb in our parsing code then it will not keep going in one direction but it will try random directions.

Thus we don’t depend on input length condition that i used in previous exercise.

Here’s how the new parse-word will now look:(note that now we no longer use ‘unparsed’)

With this and the replacing all the amb with ramb, we can get better sentences with variable lengths!