Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I just thought of something funny...your mother. -- Cheech Marin


devel / comp.lang.lisp / .Re: Style question: LOOP and multiple values

SubjectAuthor
o .Re: Style question: LOOP and multiple valuesRobert L.

1
.Re: Style question: LOOP and multiple values

<sv8179$9po$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16924&group=comp.lang.lisp#16924

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!mhnTAX5IWdp00sAAh3yfnA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: Style question: LOOP and multiple values
Date: Thu, 24 Feb 2022 13:29:14 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sv8179$9po$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="10040"; posting-host="mhnTAX5IWdp00sAAh3yfnA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Thu, 24 Feb 2022 13:29 UTC

Edi Weitz wrote:

> I wanted to write a function that reads whitespace-separated numbers
> from a string, i.e. given a string like "1 2 3 4" I wanted my function
> to return the list (1 2 3 4).
>
> Two different solutions came to mind:
>
> (defun foo1 (string)
> (loop for start = 0 then pos
> for (object pos) = (multiple-value-list
> (read-from-string string nil nil :start start))
> while object
> collect object))
>
> (defun foo2 (string)
> (let ((start 0) object result)
> (loop
> (multiple-value-setq (object start)
> (read-from-string string nil nil :start start))
> (unless object
> (return-from foo2 (nreverse result)))
> (push object result))))

Gauche Scheme and Racket:

;; For Racket only.
(require srfi/26) ;; cut

(define (read-em)
(define x (read))
(if (eof-object? x) '() (cons x (read-em))))

(with-input-from-string "2 3 4 5" (cut read-em))

===>
(2 3 4 5)


devel / comp.lang.lisp / .Re: Style question: LOOP and multiple values

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor