Re: every-other revisited (with series)

Liste des GroupesRevenir à cl scheme 
Sujet : Re: every-other revisited (with series)
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 18. Sep 2024, 23:15:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcffu9$77j9$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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)


Date Sujet#  Auteur
18 Sep23:15 o Re: every-other revisited (with series)1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal