Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Unix-ls/Racket/unix-ls.rkt
Normal file
20
Task/Unix-ls/Racket/unix-ls.rkt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#lang racket/base
|
||||
|
||||
;; Racket's `directory-list' produces a sorted list of files
|
||||
(define (ls) (for-each displayln (directory-list)))
|
||||
|
||||
;; Code to run when this file is running directly
|
||||
(module+ main
|
||||
(ls))
|
||||
|
||||
(module+ test
|
||||
(require tests/eli-tester racket/port racket/file)
|
||||
(define (make-directory-tree)
|
||||
(make-directory* "foo/bar")
|
||||
(for ([f '("1" "2" "a" "b")])
|
||||
(with-output-to-file (format "foo/bar/~a"f) #:exists 'replace newline)))
|
||||
(make-directory-tree)
|
||||
(define (ls/str dir)
|
||||
(parameterize ([current-directory dir]) (with-output-to-string ls)))
|
||||
(test (ls/str "foo") => "bar\n"
|
||||
(ls/str "foo/bar") => "1\n2\na\nb\n"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue