Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (RemoveElement element lst)
- ;if unique-left is applied to (list 1 4 2 1 5 4), the result would be (list 1 4 2 5)
- (cond
- [(empty? lst) empty]
- [(= element (first lst)) (RemoveElement element (rest lst))]
- [else (cons (first lst) (RemoveElement element (rest lst)))]))
- (define (unique-left lst)
- (cond
- [(empty? lst) empty]
- [(member? (first lst) (rest lst)) (cons (first lst) (unique-left (RemoveElement (first lst) (rest lst))))]
- [else (cons (first lst) (unique-left (rest lst)))]
- )
- )
- (define (unique-right lst)
- ;the result of applying it to (list 1 4 2 1 5 4) would be (list 2 1 5 4)
- (cond
- [(empty? lst) empty]
- [(not (member? (first lst) (rest lst))) (cons (first lst) (unique-right (rest lst)))]
- [else (unique-right (rest lst))]))
Advertisement
Add Comment
Please, Sign In to add comment