Commit b0147aec authored by Thien-Thi Nguyen's avatar Thien-Thi Nguyen

(write-punily): Handle symbols with ":" prefix specially.

parent f8e685d1
...@@ -34,8 +34,8 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ...@@ -34,8 +34,8 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
;; ;;
;; Example: ;; Example:
;; $ wc ./punify ; ./punify ./punify | wc ;; $ wc ./punify ; ./punify ./punify | wc
;; 81 355 2622 ./punify ;; 89 384 3031 ./punify
;; 0 34 694 ;; 0 42 920
;; ;;
;; TODO: Read from stdin. ;; TODO: Read from stdin.
;; Handle vectors. ;; Handle vectors.
...@@ -47,7 +47,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ...@@ -47,7 +47,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
:export (punify)) :export (punify))
(define (write-punily form) (define (write-punily form)
(if (and (list? form) (not (null? form))) (cond ((and (list? form) (not (null? form)))
(let ((first (car form))) (let ((first (car form)))
(display "(") (display "(")
(write-punily first) (write-punily first)
...@@ -60,8 +60,16 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ...@@ -60,8 +60,16 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
(not this-is-list?) (not this-is-list?)
(display " ")) (display " "))
(write-punily new-first) (write-punily new-first)
(loop (cdr ls) this-is-list?))))) (loop (cdr ls) this-is-list?))))))
(write form))) ((and (symbol? form)
(let ((ls (string->list (symbol->string form))))
(and (char=? (car ls) #\:)
(not (memq #\space ls))
(list->string (cdr ls)))))
=> (lambda (symbol-name-after-colon)
(display #\:)
(display symbol-name-after-colon)))
(else (write form))))
(define (punify-one file) (define (punify-one file)
(with-input-from-file file (with-input-from-file file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment