Dealing properly with rest args in svn-style commands
This commit is contained in:
parent
027b09fec8
commit
41a64cbbd8
|
@ -58,7 +58,7 @@
|
||||||
body ...
|
body ...
|
||||||
#:handlers
|
#:handlers
|
||||||
(λ (_ . formals) final-expr)
|
(λ (_ . formals) final-expr)
|
||||||
(pimap symbol->string 'formals)
|
(ensure-list (pimap symbol->string 'formals))
|
||||||
(λ (help-string)
|
(λ (help-string)
|
||||||
(for-each (λ (l) (display l) (newline)) (wrap-to-count long-description 80))
|
(for-each (λ (l) (display l) (newline)) (wrap-to-count long-description 80))
|
||||||
(newline)
|
(newline)
|
||||||
|
@ -98,13 +98,18 @@
|
||||||
[extra (build-string (- n l) (λ (n) #\space))])
|
[extra (build-string (- n l) (λ (n) #\space))])
|
||||||
(string-append str extra)))
|
(string-append str extra)))
|
||||||
|
|
||||||
|
(define (ensure-list x)
|
||||||
|
(if (or (null? x) (pair? x))
|
||||||
|
x
|
||||||
|
(list x)))
|
||||||
|
|
||||||
;; pimap : (A -> B) improper-listof A -> improper-listof B
|
;; pimap : (A -> B) improper-listof A -> improper-listof B
|
||||||
(define (pimap f pil)
|
(define (pimap f pil)
|
||||||
(cond
|
(cond
|
||||||
[(null? pil) '()]
|
[(null? pil) '()]
|
||||||
[(pair? pil) (cons (pimap f (car pil))
|
[(pair? pil) (cons (pimap f (car pil))
|
||||||
(pimap f (cdr pil)))]
|
(pimap f (cdr pil)))]
|
||||||
[else (list (f pil))]))
|
[else (f pil)]))
|
||||||
|
|
||||||
;; wrap-to-count : string nat -> (listof string)
|
;; wrap-to-count : string nat -> (listof string)
|
||||||
;; breaks str into substrings such that no substring
|
;; breaks str into substrings such that no substring
|
||||||
|
|
Loading…
Reference in New Issue
Block a user