[racket] testing impure stuff
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))))