Skip to content

Instantly share code, notes, and snippets.

@fogus
Created August 5, 2009 14:53
Show Gist options
  • Save fogus/162729 to your computer and use it in GitHub Desktop.
Save fogus/162729 to your computer and use it in GitHub Desktop.
(define format-row
C G [#\~ #\A |L] [X|J] -> [(format-AS human X)|(format-row C G L J)]
C G [#\~ #\S |L] [X|J] -> [(format-AS compu X)|(format-row C G L J)]
C G [#\~ #\C |L] [X|J] -> [(format-C human X)|(format-row C G L J)]
C G [#\~ #\@ #\C |L] [X|J] -> [(format-C compu X)|(format-row C G L
J)]
C G [#\~ #\P |L] [X|J] -> [(if (= X 1) [] [#\s])|(format-row C G L
J)]
C G [#\~ #\P |L] [X|J] -> [(if (= X 1) [] [#\s])|(format-row C G L
J)]
C G [#\~ #\: #\P |L] [X|J] -> [(if (= X 1) [] (explode ies)) |
(format-row C G L J)]
C G [#\~ #\~ |L] [X|J] -> [#\~|(format-row C G L J)]
C G [#\~ #\% |L] [X|J] -> [#\Newline|(format-row C G L J)]
C G [#\~ #\} |L] [X|J] -> (FUNCALL C J)
C G [#\~ #\} |L] [] -> (FUNCALL G L)
C G [#\~ #\^ |L] M -> (FUNCALL G (format-skip L))
C G [#\~ #\{ |L] [X|J] -> (let CC NIL
CG (/. LL (format-row C G LL J))
(do (SETF CC (/. U (format-row CC CG L U)))
(CC (head X)))))
(define format-skip
[#\~ #\~|L] -> (format-skip L)
[#\~ #\}|L] -> L
[X |L] -> (format-skip L))
(define format-AS
Kind [X|L] -> (let M (map (format-AS Kind) [X|L])
R (reduce (/. X L -> (if (= L [])
X
(append X [#\Space] L)))
[]
M)
(append [#\(] R [#\)]))
Kind NIL -> [#\N #\I #\L]
Kind X -> (format-string Kind X) where (string? X)
Kind X -> (format-charac Kind X) where (character? X)
Kind X -> (format-symbol Kind X) where (symbol? X)
Kind X -> (format-variab Kind X) where (variable? X)
Kind X -> (format-number Kind X) where (number? X))
(define format-C
Kind X -> (format-charac Kind X))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment