slight refactoring
[rrq/lsp-utils.git] / lsp-misc / misc.lsp
1 (define (prog1 X) X)
2 (global 'prog1)
3
4 (define (die N)
5   (when (args) (write-line 2 (join (map string (args)) " ")))
6   (exit N))
7 (global 'die)
8
9 ;; Print binary byte as octal or as ASCII character [32-126]
10 (define (octal-byte x)
11   (if (and (> x 31) (< x 127)) (char x) (format "\\%o" x)))
12
13 ;; Print string as binary octals
14 (define (octals-string S)
15   (join (map octal-byte (unpack (dup "b" (length S)) S))) "")
16 (global 'octals-string 'octal-byte)