Sujet : Re: Read-from-string
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 29. Jun 2025, 16:53:01
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103rngs$1jidh$1@dont-email.me>
References : 1
User-Agent : XanaNews/1.18.1.6
B. Pym wrote:
Pascal J. Bourguignon wrote:
words, but in reality I'll be reading from an input where the number
of words is unknown to me. Is there a way to circumvent this "repeat
3", because it would be "repeat n" and n is unknwon (it's as many
words that the string contains).
(with-input-from-string (s "lala tata bobo dada qwerty moo goo")
(loop for token = (read s nil nil nil)
while token
collect token))
(let ((data "lala tata bobo dada nil qwerty moo goo"))
(with-input-from-string (s data)
(loop for token = (read s nil nil nil)
while token
collect token)))
-> (LALA TATA BOBO DADA)
Gauche Scheme
(use srfi-42) ;; list-ec
(let ((data "lala tata bobo dada #f qwerty moo goo"))
(call-with-input-string data
(lambda(in)
(list-ec (:port token in) token))))
===>
(lala tata bobo dada #f qwerty moo goo)