1234567891011121314151617181920212223242526 |
- (define-module (data-mining test-util)
- #:use-module (srfi srfi-1) ;lset-difference
- #:export (list-permutation?
- same-map?))
- (define (list-permutation? lst)
- ;; Return a procedure which, when called, returns #t if the given
- ;; list is a permutation of LST
- (lambda (l)
- (null? (lset-difference equal? l lst))))
- (define (same-map? alst blst)
- (and (= (length alst) (length blst))
- (let loop ((head (car alst))
- (rest (cdr alst)))
- (if (null? rest)
- (and=>
- (assoc (car head) blst)
- (lambda (p)
- (equal? (cdr p) (cdr head))))
- (and (and=>
- (assoc (car head) blst)
- (lambda (p)
- (equal? (cdr p) (cdr head))))
- (loop (car rest) (cdr rest)))))))
|