This Text file is old! In a 🏛️Museum, an unsorted archive of (user-)pages. (Saved from Geocities in Oct-2009. The archival story: oocities.org)
--------------------------------------- (To 🚫report any bad content: archivehelp @ gmail.com)
>


; readintolist1.scm - copy file to new file reversing lines

; 'string:trim-right' from bevan's string extensions
; (note: doesn't work on empty-strings/blank-lines)

(define (string:trim-right source chars)
  (let ((source-length (string-length source)))
    (let loop ((current-position (- source-length 1)))
      (cond
        ((zero? current-position)
	   (if (member (string-ref source 0) chars)
	       ""
	       (substring source 0 1)))
	((member (string-ref source current-position) chars)
	   (loop (- current-position 1)))
	(else
	   (substring source 0 (+ 1 current-position)))))))

(define (trim-right-space line)
   (string:trim-right line  '(#\space #\newline #\return #\tab)))

;----------------------------------------------------------------------------------------

(define (read-into-list in-port)
   (let ((line (read-line in-port)))
      ;(if (not (eof-object? line)) (display (format "*~A*" (trim-right-space line)))) 
      (cond 
         ((eof-object? line) '())
         (else (cons (trim-right-space line) (read-into-list in-port))))))

(define (for-each-reverse proc lst)
   (cond
      ((null? lst) (void))
      (else 
         (begin 
            (for-each-reverse proc (cdr lst))
            (proc (car lst)) ))))

(define (add-crlf line)
   (string-append line (string #\return #\newline) ))

;------------------------------------------------------------------------------------

(define (file-reverse infilename outfilename)
   (let ((in-port (open-input-file infilename))
         (out-port (open-output-file outfilename 'replace)))
     (for-each-reverse 
        (lambda (line) (display (format "~A" (add-crlf line)) out-port)) 
           (read-into-list in-port))))
 
;example:
;(file-reverse "hello.txt" "hello2.txt")

;(file-reverse "dirlisting_c.txt" "dirlisting_c2.txt")

Text file Source (historic): geocities.com/soho/square/3472

geocities.com/soho/square
geocities.com/soho

(to report bad content: archivehelp @ gmail)