[customer-summary] rewrite string-expand

This commit is contained in:
Christopher Lam 2019-03-23 13:07:34 +08:00
parent 07f44ad7c5
commit 98811d7e71

View File

@ -202,22 +202,15 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (string-expand string character replace-string)
(define (car-line chars)
(take-while (lambda (c) (not (eqv? c character))) chars))
(define (cdr-line chars)
(let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
(if (null? rest)
'()
(cdr rest))))
(define (line-helper chars)
(if (null? chars)
""
(let ((first (car-line chars))
(rest (cdr-line chars)))
(string-append (list->string first)
(if (null? rest) "" replace-string)
(line-helper rest)))))
(line-helper (string->list string)))
(with-output-to-string
(lambda ()
(string-for-each
(lambda (c)
(display
(if (char=? c character)
replace-string
c)))
string))))
(define (query-toplevel-setup query account-list start-date end-date)
(xaccQueryAddAccountMatch query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)