I have a file which consists of one word per line and I would like to
read it into a single list.
Searching the web[1] I found something which I adapted to my
needs. Basically the code works but it is terribly inefficient. This
is not the fault of the CL Cookbook. Probably I am using a hammer as a screwdriver.
I'd be happy if you can give me some directions how I can tackle the problem in a better way.
I like loop for this:
(with-open-file (s "foo.txt" :direction :input)
(loop for line = (read-line s nil)
while line
collect line))
I have a file which consists of one word per line and I would like to
read it into a single list.
Searching the web[1] I found something which I adapted to my
needs. Basically the code works but it is terribly inefficient. This
is not the fault of the CL Cookbook. Probably I am using a hammer as a
screwdriver.
I'd be happy if you can give me some directions how I can tackle the
problem in a better way.
I like loop for this:
(with-open-file (s "foo.txt" :direction :input)
(loop for line = (read-line s nil)
while line
collect line))
Gauche Scheme
(use gauche.generator)
(with-input-from-file "temp.txt"
(cut generator->list read-line))
Paul Graham, May 2001:
A hacker's language is terse and hackable. Common Lisp is not.
The good news is, it's not Lisp that sucks, but Common Lisp.
I have a file which consists of one word per line and I would like to read it into a single list.
Searching the web[1] I found something which I adapted to my
needs. Basically the code works but it is terribly inefficient. This
is not the fault of the CL Cookbook. Probably I am using a hammer as a screwdriver.
I'd be happy if you can give me some directions how I can tackle the problem in a better way.
I like loop for this:
(with-open-file (s "foo.txt" :direction :input)
(loop for line = (read-line s nil)
while line
collect line))
Gauche Scheme
(use gauche.generator)
(with-input-from-file "temp.txt"
(cut generator->list read-line))
Paul Graham, May 2001:
A hacker's language is terse and hackable. Common Lisp is not.
The good news is, it's not Lisp that sucks, but Common Lisp.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 418 |
Nodes: | 16 (2 / 14) |
Uptime: | 51:05:18 |
Calls: | 8,814 |
Calls today: | 10 |
Files: | 13,307 |
Messages: | 5,973,245 |