From: Chris Huminski
Subject: lisp: file to string to list
Date: 
Message-ID: <01bcc6bf$946e96e0$0100007f@bpclppcn010>
Anyone,

Will somebody please instruct me on how to read ONE line in a multi-line
text file (containing both words and numbers separated by spaces), and then
convert that string into a list, such that all of the words and numbers are
individual members of that list (instead of one long string), being divided
up according to the spaces in the original text string?

Good assistance is much appreciated!

TIA,

Chris H

From: Barry Margolin
Subject: Re: lisp: file to string to list
Date: 
Message-ID: <603v5s$m3j@pasilla.bbnplanet.com>
In article <··························@bpclppcn010>,
Chris Huminski <······@psinet.com> wrote:
>Will somebody please instruct me on how to read ONE line in a multi-line
>text file (containing both words and numbers separated by spaces), and then
>convert that string into a list, such that all of the words and numbers are
>individual members of that list (instead of one long string), being divided
>up according to the spaces in the original text string?

Use READ-LINE to read a line into a string, and WITH-INPUT-FROM-STRING to
take input from that string:

(defun line-to-list (stream)
  (let ((string (read-line stream nil))
        (eof (cons nil nil)))
    (when string
      (with-input-from-string (s string)
        (loop for element = (read s nil eof)
	      until (eq element eof)
	      collect element)))))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.
From: Donald Fisk
Subject: Re: lisp: file to string to list
Date: 
Message-ID: <342950B3.125B@bt-sys.bt.co.spamblock.uk>
Chris Huminski wrote:
> 
> Anyone,
> 
> Will somebody please instruct me on how to read ONE line in a multi-line
> text file (containing both words and numbers separated by spaces), and then
> convert that string into a list, such that all of the words and numbers are
> individual members of that list (instead of one long string), being divided
> up according to the spaces in the original text string?
> 
> Good assistance is much appreciated!

If your input stream is f, 

(read-from-string (concatenate 'string "(" (read-line f) ")")

will do the trick, if I understand you correctly.   read-from-string
is an extremely useful, but rarely used, function.

> Chris H

-- 
Le Hibou
"What the ... This is Lambic!   Where's my culture of amoebic 
dysentery?"
			-- Gary Larson