Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You need no longer worry about the future. This time tomorrow you'll be dead.


comp / comp.lang.lisp / Re: reading-files. CLOS-support?

SubjectAuthor
o Re: reading-files. CLOS-support?B. Pym

1
Subject: Re: reading-files. CLOS-support?
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Fri, 20 Sep 2024 07:23 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: reading-files. CLOS-support?
Date: Fri, 20 Sep 2024 07:23:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vcj7tu$1095b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Fri, 20 Sep 2024 09:23:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a0826257f8080eff71f9956e8770cd16";
logging-data="1057963"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WqJS60UdjWumeef98mk+I"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:Gcey7Pndt+7TmITUkzlXbqA/Lpw=
View all headers

Pete Halverson wrote:

> > > I need to read an input file which is not written out as lists.
> > > I can use read-line and get it as a string.
> > > how do I convert this string to a list.
> > > eg of kind of lines to be read and converted
> > > Line 13.4 24 50 100.0 45.6 78
> > > eye 0 0 0
> > > aim -75 10 12
> > > One posible solution I have is to coerce the string into a list
> > > and reformulate the list by "imploding" atoms separated by blank spaces
> > > together. This doesnt work for the number portion yet.But, I am still
> > > working on it.
> >
> > Id be very interested in solutions to this as well. Id be happy to receive
> > duplicates of any email-messages showing up.
>
> I would expect something as trivial as
>
> (defconstant +EOF-MARKER+ (make-symbol "EOF"))
>
> (defun READ-TOKENS-FROM-STRING (string)
> (with-input-from-string (stream string)
> (loop for thing = (read stream nil +eof-marker+)
> until (eq thing +eof-marker+)
> collect thing)))
>
> ought to suffice here. (Apologies to loop haters; conversion to "Lisp" is
> left as an exercise to the reader :-)

Gauche Scheme:

(use gauche.generator)

(define (read-tokens-from-string string)
(with-input-from-string string
(cut generator->list read)))

1

rocksolid light 0.9.8
clearnet tor