Use spaces instead of tabs for indentation

This commit is contained in:
Camden Dixie O'Brien 2024-03-13 17:21:14 +00:00
parent 1381f0b881
commit 938fd7d41b

View File

@ -5,42 +5,42 @@
(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))))))
(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)