Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your sister swims out to meet troop ships.


comp / comp.lang.lisp / Re: every-other revisited (with series)

SubjectAuthor
o Re: every-other revisited (with series)B. Pym

1
Subject: Re: every-other revisited (with series)
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Wed, 18 Sep 2024 21:15 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: every-other revisited (with series)
Date: Wed, 18 Sep 2024 21:15:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vcffu9$77j9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 18 Sep 2024 23:15:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4958f309d49d57f6bb3fad052ff4cbda";
logging-data="237161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18f0w1ivPRtWhk3pyNrIEHT"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:hiw0apd/olhxdJbw8YaTPMTvUPQ=
View all headers

Fred Gilham wrote:

> For those who are interested, here are two versions of the
> `every-other' function we were discussing a couple months ago, done
> for amusement value with the SERIES package that was mentioned
> recently:
>
>
> (defun every-other (list &key (start 0))
> (collect
> (choose (series t nil)
> (scan (nthcdr start list)))))
>
>
> This one uses SERIES to create a series of (t nil t nil ...); CHOOSE
> uses this series to determine whether or not to take the current item
> from the series created from the original list by SCAN. This was the

Gauche Scheme

(use srfi-1) ; circular-list

(define (every-other lst)
(filter-map
(cut and <> <>)
(circular-list #t #f)
lst))

(every-other (iota 22))
===>
(0 2 4 6 8 10 12 14 16 18 20)

1

rocksolid light 0.9.8
clearnet tor