; Test of Set and HSet (map (lambda (set) (let ((set ((fileVal set) -))) (and ((set 'empty?) (set 'empty)) (= 13 ((set 'choose) ((set 'add) 13 (set 'empty)))) (let ((lm 50000) (em (set 'empty)) (add (set 'add)) (se (set 'equal?))) (let ((up em) (dn em) (md em)) (((fileVal "Do") 'Do) lm (lambda (i) (set! up (add i up)) (set! dn (add (- (- lm 1) i) dn)) (set! md (add (modulo (* i 23) lm) md)))) (and (se up dn) (se up md) (= lm ((set 'cardinal) up)) (let ((p ((set 'partition) (let ((p (/ lm 3))) (lambda (q) (< q p))) md))) (se ((set 'union) (car p) (cdr p)) md))))) (let ((F ((fileVal "Farey") 500))) (let L ((F F)) (or (null? (cdr F)) (and (= (- (* (numerator (cadr F)) (denominator (car F))) (* (numerator (car F)) (denominator (cadr F)))) 1) (L (cdr F)))))) (let* ((ri (let ((r (((fileVal "RC4") "ZooM") 'nb)))(lambda () (r 2)))) (empty (set 'empty))(add (set 'add))) (let ((ls (let w ((n 3000) (a empty) (b empty) (c empty)) (if (= n 0) (list a b c) (let ((m (ri))) (w (- n 1) (if (= (modulo m 2) 0) (add m a) a) (if (= (modulo m 8) 0) (add m b) b) (if (= (modulo m 3) 0) (add m c) c))))))) ; (map (set 'elements) ls) (let ((a (car ls)) (b (cadr ls)) (c (caddr ls)) (U (set 'union)) (I (set 'inter))) (and ((set 'subset) b a) (not ((set 'subset) (add 1301 b) a)) ((set 'equal?) (U (I a b) (I a c)) (I a (U b c))) ((set 'equal?) (I (U a b) (U a c)) (U a (I b c))) (equal? (reverse ((set 'elements) a)) ((set 'fold) cons a '())))))) (let ((s '(3 6 7 22))) (equal? s ((set 'elements) ((set 'these) s)))) ))) (list "Set" "HSet")) ; test: singleton, remove, diff, iter, for_all, exists, filter