[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: case and quoted keys - a misunderstanding

William James

7/25/2015 9:59:00 AM

Frode Vatvedt Fjeld wrote:

> > (defun read-to-char (c stream)
> > (let ((x (read-char stream nil)))
> > (cond ((null x) nil)
> > ((char= x c) t)
> > (t (read-to-char c stream)))))
> >
> > This isn't much worse looking then the obvious iterative solutions.
>
> ..only it has Scheme written all over it ;-) In Common Lisp this is
> spelled as
>
> (defun read-to-char (c stream)
> (loop for x = (read-char stream nil)
> while x do (when (char= x c) (return t))))

Gauche Scheme:

(define (read-to-char c port)
(generator-find
(cut char=? c <>)
(cut read-char port)))

--
He has nothing but kind sentiments for those who would destroy his home and
family.... He is universally tolerant. He is totally unprejudiced. 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?"