#!/usr/bin/newlisp # # Find the newest file of each of the given directories ;; Return pair (time file) for given file (define (modtime F) (if (null? F) '(0 F) (list? F) F (list (file-info F 6) F))) (define (files-in D) (clean (fn (x) (or (= x ".") (= x ".."))) (directory D ""))) ;; Return the list of full pathnames for all files in the given ;; directory, excluding "." and "..". (define (dir-list D) (if (= D ".") (files-in D) (map (fn (F) (format "%s/%s" D F)) (files-in D)))) ;; Return pair of (time file) (define (newest FILES) ;;(println (list 'newest FILES)) (if (null? FILES) '() (last (sort (map modtime (map (fn (F) (if (directory? F) (newest (dir-list F)) F)) FILES)))))) (define (report x) (format "%s %s" (date (x 0)) (x 1))) (map println (map report (sort (map newest (map list (2 (main-args))))))) (exit 0)