Parsing through a list with prolog