[racket] testing impure stuff

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Dec 23 15:20:32 EST 2013

For that, you will need to wrap the whole loop because (in-directory ...) fails, and no, I don't know how to resume this optimized loop: 

#lang racket ;; foo.rkt 

(define start-dir ".")

;;
(with-handlers (((lambda (x) #t) (lambda (e) (log-warning "in-directory failed"))))
  (for ([f (in-directory start-dir)] #:when (regexp-match #rx"\\.rkt" f))
    (with-handlers ((exn:fail:contract? (lambda (e) (log-warning (exn-message e))))
		    (exn? displayln))
      (displayln (path->string f)))))



On Dec 23, 2013, at 3:06 PM, Manfred Lotz <manfred.lotz at arcor.de> wrote:

> #lang racket ;; foo.rkt 
> 
> (define start-dir "/tmp/testdir")
> 
> (for ([f (in-directory start-dir)] #:when (regexp-match #rx"\\.rkt" f))
>  (with-handlers ((exn:fail:contract? (lambda (e) (log-warning
>            (exn-message e))))) 
>  (displayln (path->string f))))



Posted on the users mailing list.