-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-function.scm
More file actions
25 lines (25 loc) · 1.18 KB
/
test-function.scm
File metadata and controls
25 lines (25 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(define (replace-numbered-patterns str)
(let ((len (string-length str)))
(let loop ((i 0) (acc '()))
(if (>= i len)
(string-join (reverse acc) "")
(let ((linebreak-label
(and (< (+ i 1) len)
(char=? (string-ref str i) #\\)
(char=? (string-ref str (+ i 1)) #\\)
(parse-numbered-label str (+ i 2))))
(hskip-label
(or (parse-horizontal-skip-label str i "\\hskip")
(parse-horizontal-skip-label str i "\\hspace*")
(parse-horizontal-skip-label str i "\\hspace"))))
(cond
(linebreak-label
(loop (cdr linebreak-label)
(cons (string-append "\\qquad" (car linebreak-label))
acc)))
(hskip-label
(loop (cdr hskip-label)
(cons (string-append "\\qquad" (car hskip-label))
acc)))
(else
(loop (+ i 1) (cons (string (string-ref str i)) acc)))))))))