[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: word puzzle

William James

3/28/2015 3:03:00 AM

Pascal Bourguignon wrote:

> (setf lexicon
> (with-open-file (file "word.data")
> (let ((*read-eval* nil))
> (loop with lex = (make-array 0 :adjustable t)
> for word = (read file nil nil)
> while word
> do (vector-push-extend word lex)
> finally (return lex)))))

Evidently he is trying to read words from a file
and put them into a vector.

Let's see if that crap even runs.

Armed Bear Common Lisp 0.12.0:

Debugger invoked on condition of type TYPE-ERROR:
The value #() is not of type
(AND VECTOR (SATISFIES ARRAY-HAS-FILL-POINTER-P)).

SBCL:

debugger invoked on a SIMPLE-TYPE-ERROR:
#() is not an array with a fill pointer.


Worshippers of CL (COBOL-Like) are disasters.
They have no interest in correct programming or
efficient programming or elegant programming.

They only want to worship their CL god.


Gauche Scheme:

Contents of file:
one two
three


(use srfi-42) ; vector-ec

(call-with-input-file "word.data"
(lambda (port)
(vector-ec (: word port) word)))

===>
#(one two three)
1 Answer

William James

1/14/2016 11:00:00 AM

0

WJ wrote:

> Pascal Bourguignon wrote:
>
> > (setf lexicon
> > (with-open-file (file "word.data")
> > (let ((*read-eval* nil))
> > (loop with lex = (make-array 0 :adjustable t)
> > for word = (read file nil nil)
> > while word
> > do (vector-push-extend word lex)
> > finally (return lex)))))
>
> Evidently he is trying to read words from a file
> and put them into a vector.

MatzLisp (Ruby):

IO.read("input.txt").split

--
He has nothing but kind sentiments for those who would destroy his home and
family.... He is universally tolerant.... If he has any principles, he keeps
them well concealed.... He is, to the extent of his abilities, exactly like
the next citizen, who, he trusts, is trying to be exactly like him: a faceless,
characterless putty-man. --- Father Feeney; "Should Hate Be Outlawed?"