• Re: Read-from-string

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Sun Jun 29 15:53:01 2025
    From Newsgroup: comp.lang.lisp

    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)
    --- Synchronet 3.21d-Linux NewsLink 1.2