exercise 4 partial

merge$ works, however defining S is a bit jenky