From: Gary Dodds
Subject: read into lists
Date: 
Message-ID: <hzgG7.2252$_R2.419368@news11-gui.server.ntli.net>
Hi

how can I read input from the keyboard into a list

Gary

From: Thomas F. Burdick
Subject: Re: read into lists
Date: 
Message-ID: <xcvzo5y6wv1.fsf@conquest.OCF.Berkeley.EDU>
"Gary Dodds" <············@hotmail.com> writes:

> Hi
> 
> how can I read input from the keyboard into a list

Assuming that the keyboard is attached to *standard-input*

  (loop with eof = (gensym)
        for thing = (read *standard-input* nil eof)
	until (eq thing eof)
	collect thing)

Mmmmmm, tastes like ALGOL...

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Kent M Pitman
Subject: Re: read into lists
Date: 
Message-ID: <sfw668mmas5.fsf@world.std.com>
···@conquest.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> "Gary Dodds" <············@hotmail.com> writes:
> 
> > how can I read input from the keyboard into a list
> 
> Assuming that the keyboard is attached to *standard-input*
> 
>   (loop with eof = (gensym)
>         for thing = (read *standard-input* nil eof)
> 	until (eq thing eof)
> 	collect thing)
> 
> Mmmmmm, tastes like ALGOL...

I don't recall ALGOL having a collection facility. :-)

Btw, I think if you're really expecting to talk to the keyboard,
you should plan for a stop condition other than eof, since it's
OS-dependent whether an eof can be forced on the keyboard and it's
OS-dependent whether a Lisp will still be running after you do
force an eof on those that let you do so.  No point in doing all
that collection if you're not going to ever return the value.
From: Thomas F. Burdick
Subject: Re: read into lists
Date: 
Message-ID: <xcvr8ra6r8f.fsf@conquest.OCF.Berkeley.EDU>
Kent M Pitman <······@world.std.com> writes:

> ···@conquest.OCF.Berkeley.EDU (Thomas F. Burdick) writes:
> 
> > "Gary Dodds" <············@hotmail.com> writes:
> > 
> > > how can I read input from the keyboard into a list
> > 
> > Assuming that the keyboard is attached to *standard-input*
> > 
> >   (loop with eof = (gensym)
> >         for thing = (read *standard-input* nil eof)
> > 	until (eq thing eof)
> > 	collect thing)
> > 
> > Mmmmmm, tastes like ALGOL...
> 
> I don't recall ALGOL having a collection facility. :-)

I didn't say what it smells like :-)

> Btw, I think if you're really expecting to talk to the keyboard,
> you should plan for a stop condition other than eof, since it's
> OS-dependent whether an eof can be forced on the keyboard and it's
> OS-dependent whether a Lisp will still be running after you do
> force an eof on those that let you do so.  No point in doing all
> that collection if you're not going to ever return the value.

True, but this'll work for Windows and Unix.  In my copy of CLISP, if
you type this at the toplevel, you don't get to *do* anything with the
list (it exits immediately), but you do get to see it returned.  I
guess add the assumption of being able to generate EOF from the
keyboard, and I stand by my code.  It gets everything into the list,
just like it was supposed to.  As for its usefulness...

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Geoff Summerhayes
Subject: Re: read into lists
Date: 
Message-ID: <tujc38b3dr0q6c@corp.supernews.com>
"Gary Dodds" <············@hotmail.com> wrote in message
··························@news11-gui.server.ntli.net...
> Hi
>
> how can I read input from the keyboard into a list
>


(defun read-keyboard-into-list()
  "Why couldn't it be April 1st?"
  (let ((*read-eval* nil))
    (ignore-errors
      (cons (read)
        (read-keyboard-into-list)))))

-------------------
Geoff
From: Geoff Summerhayes
Subject: Re: read into lists
Date: 
Message-ID: <tujcsptdgmgh9f@corp.supernews.com>
"Geoff Summerhayes" <·············@hNoOtSmPaAiMl.com> wrote in message
···················@corp.supernews.com...
>
> "Gary Dodds" <············@hotmail.com> wrote in message
> ··························@news11-gui.server.ntli.net...
> > Hi
> >
> > how can I read input from the keyboard into a list
> >
>
>
> (defun read-keyboard-into-list()
>   "Why couldn't it be April 1st?"
>   (let ((*read-eval* nil))
>     (ignore-errors
>       (cons (read)
>         (read-keyboard-into-list)))))
>

Oops, my bad. :-)

(defun read-keyboard-into-list()
  "Why couldn't it be April 1st?"
  (let ((*read-eval* nil))
    (cons
      (ignore-errors (read))
      (read-keyboard-into-list))))

----------------
Geoff
From: Erik Haugan
Subject: Re: read into lists
Date: 
Message-ID: <87elnaqovs.fsf@kometknut.neitileu.no>
* "Gary Dodds" <············@hotmail.com>
> how can I read input from the keyboard into a list

Common Lisp has no notion of keyboards, but reading from *standard-input* or
*terminal-io* may or may not be what you want.  Can you please give some
more information on what you're trying to do?  If it's homework, please say
so.  What textbook are you using?

Erik
From: Tim Bradshaw
Subject: Re: read into lists
Date: 
Message-ID: <fbc0f5d1.0111080313.617021e@posting.google.com>
"Gary Dodds" <············@hotmail.com> wrote in message news:<·····················@news11-gui.server.ntli.net>...
> Hi
> 
> how can I read input from the keyboard into a list

With a camera and some image recongition software.  It's non-trivial.
The result is usually (q w e r t y u i o p ...) though unless you live
in some country with mutant keyboards.