Created
April 23, 2025 07:25
-
-
Save rebekah/194ac9b69c6d975e24d81a4623913631 to your computer and use it in GitHub Desktop.
no-repeat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (is-already-present? val lst) | |
(if(null? lst) | |
#f | |
(if(= val (car lst)) | |
#t | |
(is-already-present? val (cdr lst)) | |
) | |
) | |
) | |
(define (no-repeats s) | |
(define (process-s rest tracker) | |
(if(null? rest) | |
nil | |
(if (is-already-present? (car rest) tracker) | |
(process-s (cdr rest) tracker) | |
(begin | |
(define tracker (append tracker (list (car rest)))) | |
(cons (car rest) (process-s (cdr rest) tracker)) | |
) | |
) | |
) | |
) | |
(cons (car s) (process-s (cdr s) (cons (car s) nil))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment