Program manipulating lists and pairs in Scheme