Use spaces instead of tabs for indentation
This commit is contained in:
parent
1381f0b881
commit
4255f1fe43
@ -4,43 +4,43 @@
|
||||
(define (tsv-fields line)
|
||||
(reverse
|
||||
(let iter ((len (string-length line))
|
||||
(rem (string-copy line))
|
||||
(idx 0)
|
||||
(res '()))
|
||||
(cond ((>= idx len) (cons rem res))
|
||||
((char=? #\tab (string-ref rem idx))
|
||||
(iter (- len idx 1)
|
||||
(substring rem (+ idx 1) len)
|
||||
0
|
||||
(cons (substring rem 0 idx) res)))
|
||||
(else (iter len rem (+ idx 1) res))))))
|
||||
(rem (string-copy line))
|
||||
(idx 0)
|
||||
(res '()))
|
||||
(cond ((>= idx len) (cons rem res))
|
||||
((char=? #\tab (string-ref rem idx))
|
||||
(iter (- len idx 1)
|
||||
(substring rem (+ idx 1) len)
|
||||
0
|
||||
(cons (substring rem 0 idx) res)))
|
||||
(else (iter len rem (+ idx 1) res))))))
|
||||
|
||||
(define (vcard name number)
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(display "BEGIN:VCARD")
|
||||
(newline)
|
||||
(display "N:;")
|
||||
(display name)
|
||||
(display ";;;")
|
||||
(newline)
|
||||
(display "TEL;TYPE=cell:")
|
||||
(display number)
|
||||
(newline)
|
||||
(display "END:VCARD")
|
||||
(newline))))
|
||||
(lambda ()
|
||||
(display "BEGIN:VCARD")
|
||||
(newline)
|
||||
(display "N:;")
|
||||
(display name)
|
||||
(display ";;;")
|
||||
(newline)
|
||||
(display "TEL;TYPE=cell:")
|
||||
(display number)
|
||||
(newline)
|
||||
(display "END:VCARD")
|
||||
(newline))))
|
||||
|
||||
(define (tsv-contact->vcard line)
|
||||
(let* ((fields (tsv-fields line))
|
||||
(number (list-ref fields 0))
|
||||
(name (list-ref fields 1)))
|
||||
(vcard name number)))
|
||||
(number (list-ref fields 0))
|
||||
(name (list-ref fields 1)))
|
||||
(vcard name number)))
|
||||
|
||||
(define (foreach-line thunk)
|
||||
(let loop ()
|
||||
(let ((line (get-line (current-input-port))))
|
||||
(unless (eof-object? line)
|
||||
(display (thunk line))
|
||||
(loop)))))
|
||||
(let ((line (get-line (current-input-port))))
|
||||
(unless (eof-object? line)
|
||||
(display (thunk line))
|
||||
(loop)))))
|
||||
|
||||
(foreach-line tsv-contact->vcard)
|
||||
|
Loading…
x
Reference in New Issue
Block a user