test-util.scm 709 B

1234567891011121314151617181920212223242526
  1. (define-module (data-mining test-util)
  2. #:use-module (srfi srfi-1) ;lset-difference
  3. #:export (list-permutation?
  4. same-map?))
  5. (define (list-permutation? lst)
  6. ;; Return a procedure which, when called, returns #t if the given
  7. ;; list is a permutation of LST
  8. (lambda (l)
  9. (null? (lset-difference equal? l lst))))
  10. (define (same-map? alst blst)
  11. (and (= (length alst) (length blst))
  12. (let loop ((head (car alst))
  13. (rest (cdr alst)))
  14. (if (null? rest)
  15. (and=>
  16. (assoc (car head) blst)
  17. (lambda (p)
  18. (equal? (cdr p) (cdr head))))
  19. (and (and=>
  20. (assoc (car head) blst)
  21. (lambda (p)
  22. (equal? (cdr p) (cdr head))))
  23. (loop (car rest) (cdr rest)))))))