You can read words as Lisp characters, just a few lines of code:
(defun read-words (file-name)
(with-open-file (stream file-name)
(loop while (peek-char nil stream nil nil)
collect (read stream))))
An example input file is words.txt:
attack attempt attention attraction authority automatic awake
bright broken brother brown brush bucket building
comfort committee common company comparison competition
Reading file:
> (read-words "words.txt")
=> (ATTACK ATTEMPT ATTENTION ATTRACTION AUTHORITY AUTOMATIC AWAKE BRIGHT BROKEN BROTHER BROWN BRUSH BUCKET BUILDING COMFORT COMMITTEE COMMON COMPANY COMPARISON COMPETITION)
A case can be saved by including characters in pipes (|) or by declaring them as strings:
|attack| "attempt" ...
Lossless Reading:
> (read-words "words.txt")
=> (|attack| "attempt" ...)
source
share