home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / runtime / debug-utils.scm < prev    next >
Encoding:
Text File  |  1994-09-27  |  692 b   |  34 lines  |  [TEXT/CCL2]

  1.  
  2. ;;; This has some diagnostic stuff
  3.  
  4. ;;; This forces all delays in a structure
  5.  
  6. (define (force-all x)
  7.   (cond ((delay? x)
  8.      (force-all (force x)))
  9.     ((pair? x)
  10.      (force-all (car x))
  11.      (force-all (cdr x)))
  12.     ((vector? x)
  13.      (dotimes (i (vector-length x))
  14.             (force-all (vector-ref x i)))))
  15.   x)
  16.  
  17. ;;; This forces & removes all delays in a structure.
  18.  
  19. (define (remove-delays x)
  20.   (cond ((delay? x)
  21.      (remove-delays (force x)))
  22.     ((pair? x)
  23.      (cons (remove-delays (car x))
  24.            (remove-delays (cdr x))))
  25.     ((vector? x)
  26.      (list->vector (map (function remove-delays) (vector->list x))))
  27.     (else x)))
  28.  
  29. (define (delay? x)
  30.   (and (pair? x)
  31.        (or (eq? (car x) '#t)
  32.        (eq? (car x) '#f))))
  33.  
  34.