Print adjacent duplicates of a list (scheme)
问题 I'm trying to create a function that returns the adjacent duplicates of a list, for example (dups '(1 2 1 1 1 4 4) should return the list (1 4). This is the code I came up with so far: (define (dups lst) (if (equal? (car lst)(car(cdr lst))) (cons(cdr lst) '()) (dups(cdr lst)))) This function doesn't return all the adjacent duplicates, it only returns the first adjacent duplicates! How can I fix it so that it returns all the adjacent duplicates of a list? Thank you. 回答1: Once your code finds a