Deutsch English Français Italiano |
<vcffu9$77j9$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "B. Pym" <Nobody447095@here-nor-there.org> 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= Bytes: 1669 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)