Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You can rent this space for only $5 a week.


comp / comp.lang.lisp / Re: Loop? ptooey

SubjectAuthor
o Re: Loop? ptooeyB. Pym

1
Subject: Re: Loop? ptooey
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Sat, 15 Jun 2024 23:16 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Loop? ptooey
Date: Sat, 15 Jun 2024 23:16:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <v4l7co$3mbej$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sun, 16 Jun 2024 01:16:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="61b0a6be1e9217d59a0b088ed74d8c3f";
logging-data="3878355"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+N2SEgx6v5aiexzQR7uima"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:StIQuDzFkeCEnJhmdU5rjEqtAu8=
View all headers

> Kenny Tilton wrote:
>
> > > KMP: The example you cite is quite simplistic.....snip...A
> > > loop like this:
> > >
> > > (loop for x from 0
> > > for y in some-list
> > > when (good-result? y)
> > > collect (list x y))
> > >
> > > is easy to write and maintain, and much easier to explain than the
> > > equivalent, but more Lispy:
> > >
> > > (do ((x 0 (+ x 1))
> > > (y-list some-list (cdr y-list))
> > > (result '()))
> > > ((null y-list) ;; [fixed]
> > > (nreverse result))
> > > (let ((y (first y-list)))
> > > (when (good-result? y)
> > > (push (list x y) result))))
> >
> > Ugh. Howse about:
> >
> > (let ((goody-pos -1)
> > goodies)
> > (dolist (it some-list (nreverse goodies))
> > (incf goody-pos)
> > (when (good-result? it)
> > (push (list goody-pos it) goodies))))
> >
> > perhaps i will be swayed someday by the charms of loop, but i gotta
> > tell you, i just don't get it. is loop for people who can't read lisp?
> > can't be, lisp is easier to read than loop. stumped.

Gauche Scheme:

(use srfi-42) ;; list-ec

(define some-list '(3 4 5 7 8))

(list-ec
(:list x (index i) some-list)
(if (odd? x))
(list i x))

===>
((0 3) (2 5) (3 7))

1

rocksolid light 0.9.8
clearnet tor