Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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