scsh-users
[Top] [All Lists]

Re: find in Scsh -- functional systems hacking

To: shivers@ai.mit.edu
Subject: Re: find in Scsh -- functional systems hacking
From: Brent Benson <bwb@concentra.com>
Date: Tue, 6 Feb 1996 14:56:25 -0500
Cc: scsh@martigny.ai.mit.edu
# Date: 06 Feb 1996 09:29:31 -0500
# From: shivers@ai.mit.edu (Olin Shivers)

There's a missing paren in this function:
 
# (define (file-tree-recur root dirfunc leaffunc . state)
#   ;; These ...-carefully procs return #f or '() if there's an error.
#   (letrec ((file-info-carefully (lambda (f)
#                                 (with-errno-handler ((errno misc) (else #f))
#                                   (file-info f #f))))
#          (directory-files-carefully (lambda (f)
#                                       (with-errno-handler
#                                           ((errno misc) (else '()))
#                                         (directory-files f))))
# 
#          ;; This is the real core of the procedure.
#          (rft (lambda (root . state)
#                 ;; "What is this thing called ROOT?"
#                 (let ((info (file-info-carefully root)))
#                   (if (not info) (apply values state) ; Unix is shy; give up.
# 
#                       (case (file-info:type info)
# 
#                         ((directory)  ; ROOT is a directory => recurse.
#                          (let ((dir (file-name-as-directory root)))
#                            (apply dirfunc root info
#                                   (map (lambda (f) (string-append dir f))
#                                        (directory-files-carefully root))
#                                   rft
#                                   state)))
# 
#                         (else (apply leaffunc root info state)))))))
# 
#          ;; Ugh. I'm completely special-casing the pure-side-effect one.
#          (rft0 (lambda (root)
#                  (let ((info (file-info-carefully root)))
#                    (if info
#                        (case (file-info:type info)
#                          ((directory)
#                           (let ((dir (file-name-as-directory root)))
#                             (dirfunc root info
#                                      (map (lambda (f) (string-append dir f))
#                                           (directory-files-carefully root))
#                                      rft0))
---------------------------------------------^

Missing paren.

#                          (else (leaffunc root info))))))))
#     
#     (if (pair? state)
#       (apply rft root state)
#       (begin (rft0 root) (values)))))
#          
# 
# ;;; Multiple-value list-reduce: apply (f elt . sv) => sv' across the list.
# 
# (define (mv-reduce f lis . state-vals)
#   (letrec ((recur (lambda (lis . state-vals)
#                   (if (pair? lis)
#                       (let ((elt (car lis))
#                             (lis (cdr lis)))
#                         (receive state-vals (apply f elt state-vals)
#                           (apply recur lis state-vals)))
#                       (apply values state-vals)))))
#     (apply recur lis state-vals)))
# 

<Prev in Thread] Current Thread [Next in Thread>