From d32b24edb5575592ea12bc30dacf8ad50e3189cc Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 5 Nov 2019 14:01:15 -0800 Subject: [PATCH] tidy loop --- pollen/private/ts.rktd | 2 +- pollen/render.rkt | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index b6ed611..e4bc76b 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1572980884 +1572991275 diff --git a/pollen/render.rkt b/pollen/render.rkt index 31c169a..22e595f 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -59,19 +59,15 @@ [wants-parallel-render (define source-paths - (remove-duplicates - (let loop ([paths paths-in]) - (match paths - [(cons path0 rest) - (define paths-to-append - (match (->complete-path path0) - [(? pagetree-source? pt) (loop (pagetree->paths pt))] - [path (define sp (->source-path path)) - (cond - [(and sp (file-exists? sp)) (list sp)] - [else null])])) - (append paths-to-append rest)] - [_ null])))) + (for/fold ([paths paths-in] + [acc null] + #:result (remove-duplicates acc)) + ([i (in-naturals)] + #:break (null? paths)) + (match (->complete-path (car paths)) + [(? pagetree-source? pt) (values (append (pagetree->paths pt) (cdr paths)) acc)] + [(? ->source-path sp) #:when (file-exists? sp) (values (cdr paths) (cons sp acc))] + [_ (values (cdr paths) acc)]))) (define job-count (match wants-parallel-render