File: remove-extra-blank-lines.sc

package info (click to toggle)
stalin 0.11-6
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 110,396 kB
  • ctags: 163,122
  • sloc: ansic: 1,757,574; lisp: 88,332; sh: 1,514; makefile: 229; sed: 100; csh: 30
file content (27 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (5)
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
26
27
;;; LaHaShem HaAretz U'Mloah

(module main (main main))

(define (read-line . port)
 (let loop ((chars '()))
  (let ((char (read-char)))
   (if (eof-object? char)
       (if (null? chars) char (list->string (reverse chars)))
       (if (char=? char #\newline)
	   (list->string (reverse chars))
	   (loop (cons char chars)))))))

(define (main)
 (let loop ((flag? #t))
  (let ((line (read-line)))
   (unless (eof-object? line)
    (cond ((string=? line "")
	   (unless flag?
	    (display line)
	    (newline))
	   (loop #t))
	  (else (display line)
		(newline)
		(loop #f)))))))

;;; Tam V'Nishlam Shevah L'El Borei Olam