[plt-scheme] Fooling around w/files and directories

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Jun 23 11:07:23 EDT 2009

Since my tiny little example of directory processing is getting me  
several comments, I rewrote it in the densest possible Haskellian  
style I could think of, all within my favorite 80-column width and  
with one line for the original poster retained :)

#lang scheme

;; (U Path String) -> [Listof String]
;; all numbered jpgs in directory dir in the order of the numbers  
they contain
(define (get-jpgs dir)
   (define d (directory-list dir))
   (define e (filter (curry regexp-match "\\.jpg$") (map path->string  
d)))
   (sort e < #:key (compose string->number cadr (curry regexp-match  
"([0-9]+)"))))


Posted on the users mailing list.