Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (define (set-equal? a b)
- (cond
- [(and (empty? a) (empty? b)) #t]
- [(or (empty? a) (empty? b)) #f]
- [else (let ([snipped (remove (car a) b)])
- (and snipped (set-equal? (cdr a) snipped)))]
- )
- )
- (define (amb-equal? a b)
- (if (and (list? a) (list? b)) (set-equal? a b)
- (equal? a b)
- )
- )
- (define (remove ele set [acc '()])
- (cond
- [(empty? set) #f]
- [(amb-equal? (car set) ele) (append (reverse acc) (cdr set))]
- [else (remove ele (cdr set) (cons (car set) acc))]
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement