RE-EDIT:
Based on the comments you've made below, it looks to me like you're actually going to be writing this algorithm in Racket.
In that case, I have a much simpler prescription for you: Don't Do Anything. In particular, your input doesn't currently contain any spaces at all. The spaces you see are being inserted as part of Racket's display mechanism, in much the same way that a database printer might print fields separated with commas or tabs.
Rather than worrying about the commas, focus on the resolution algorithm. What does it take, and what does it produce?