Created
August 7, 2020 11:13
-
-
Save microamp/95642fd5c9326cbb5ccb152cc617842f to your computer and use it in GitHub Desktop.
set? with no helper function
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
#lang racket | |
(define set? | |
(lambda (lat) | |
(cond | |
[(null? lat) #t] | |
[(null? (cdr lat)) #t] | |
[(eq? (car lat) (car (cdr lat))) #f] | |
[else (and (set? (cons (car lat) (cdr (cdr lat)))) | |
(set? (cdr lat)))]))) | |
(set? '()) ;; #t | |
(set? '(a)) ;; #t | |
(set? '(a b)) ;; #t | |
(set? '(a a)) ;; #f | |
(set? '(a b c d e)) ;; #t | |
(set? '(a b c b a)) ;; #f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment