[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: beginner question on input from large files

William James

5/23/2015 6:41:00 AM

Erik Naggum wrote:

> if you're not as silly as to have an allergic reaction to LOOP, this is
> even better:
>
> (defun stream-lines (input-stream)
> (loop for line = (read-line input-stream nil :eof)
> until (eq line :eof)
> collect line))

Gauche Scheme:

(use srfi-42 :only (list-ec))
(define (port-lines input-port)
(list-ec (:port line input-port read-line) line))


Another way:

(define (port-lines input-port)
(generator-map identity (cut read-line input-port)))


The easiest way:

(port->string-list port)

--
This is war, and our greatest enemy is the enemy within: the submissive,
apologetic, guilt-ridden, self-hating drone. The moment we manage to destroy
the enemy within, destroying the rest of our enemies will be a walk in the
park. http://www.kolumbus.fi/aquilon/londonsp...