From: Stephen Adams Date: Thu, 5 Jan 1995 22:31:00 +0000 (+0000) Subject: Added KMP-PROGRAM-SIZE which yields the number of pairs in a X-Git-Tag: 20090517-FFI~6837 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=bf196706936065e15386ef05962411fef3f3e6b4;p=mit-scheme.git Added KMP-PROGRAM-SIZE which yields the number of pairs in a KMP-scheme program. This is indicative of the size of the program. --- diff --git a/v8/src/compiler/midend/utils.scm b/v8/src/compiler/midend/utils.scm index 45040e142..6ba183731 100644 --- a/v8/src/compiler/midend/utils.scm +++ b/v8/src/compiler/midend/utils.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: utils.scm,v 1.6 1994/11/26 22:06:43 gjr Exp $ +$Id: utils.scm,v 1.7 1995/01/05 22:31:00 adams Exp $ Copyright (c) 1994 Massachusetts Institute of Technology @@ -1062,3 +1062,12 @@ MIT in each case. |# (define (code/rewrite-table/copy table) (hash-table/copy table code/rewrite-table/make)) + +(define (kmp-program-size program) + (let walk ((program program) (size 0)) + (cond ((not (pair? program)) + size) + ((QUOTE/? program) + (+ size 1)) + (else + (walk (car program) (walk (cdr program) (+ size 1))))))) \ No newline at end of file