From 4e987026148fe65c323afbc93cd560c07bf06b3f Mon Sep 17 00:00:00 2001 From: Yale AI Dept Date: Wed, 14 Jul 1993 13:08:00 -0500 Subject: Import to github. --- runtime/debug-utils.scm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 runtime/debug-utils.scm (limited to 'runtime/debug-utils.scm') diff --git a/runtime/debug-utils.scm b/runtime/debug-utils.scm new file mode 100644 index 0000000..e5fa971 --- /dev/null +++ b/runtime/debug-utils.scm @@ -0,0 +1,33 @@ + +;;; This has some diagnostic stuff + +;;; This forces all delays in a structure + +(define (force-all x) + (cond ((delay? x) + (force-all (force x))) + ((pair? x) + (force-all (car x)) + (force-all (cdr x))) + ((vector? x) + (dotimes (i (vector-length x)) + (force-all (vector-ref x i))))) + x) + +;;; This forces & removes all delays in a structure. + +(define (remove-delays x) + (cond ((delay? x) + (remove-delays (force x))) + ((pair? x) + (cons (remove-delays (car x)) + (remove-delays (cdr x)))) + ((vector? x) + (list->vector (map (function remove-delays) (vector->list x)))) + (else x))) + +(define (delay? x) + (and (pair? x) + (or (eq? (car x) '#t) + (eq? (car x) '#f)))) + -- cgit v1.2.3