scheme shell
about
download
support
resources
docu
links
 
scsh.net

Filter Input Deleting Duplicate Lines

 #!/usr/local/bin/scsh \
 -o tables -e main -s

USAGE: delete-duplicate-lines.scm < INPUT > OUTPUT Copy std INPUT to std OUTPUT w/o duplicates of lines !#

;; Copy the lines of stdin to stdout ;; adding raunch and excitement. (define (delete-duplicate-lines) (let ((previous-lines (make-string-table))) (awk (read-line) (line) () ((table-ref previous-lines line)) (else (table-set! previous-lines line #t) (display line) (newline)))))

(define (main args) (if (= (length args) 1) (delete-duplicate-lines) (format #t "Usage: ~a < INPUT > OUTPUT~%" (first args))))


FilterInputDeletingDuplicateLines - raw wiki source | code snippets archive