Problem 3: No Repeats (100 pts)
Implement no-repeats
, which takes a list of numbers s
as input and returns a list that has all of the unique elements of s
in the order that they first appear, but no repeats. For example, (no-repeats (list 5 4 5 4 2 2))
evaluates to (5 4 2)
.
Hints: To test if two numbers are equal, use the =
procedure. To test if two numbers are not equal, use the not
procedure in combination with =
. You may find it helpful to use the filter-lst
procedure.
(define (no-repeats s)
'YOUR-CODE-HERE
)
;;; Tests
; scm> (no-repeats (list 5 4 5 4 2 2))
; (5 4 2)