Sujet : Re: MAP (and variants) vs LOOP - Popular opinion observation?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.schemeDate : 08. Sep 2024, 14:06:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbk3vn$1tpt1$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Then suppose you later need the loop/map to collect some of the values
under certain conditions. You might have
(loop for x in (get-list)
for i from 0
do (format t "~A - ~A~%" i x)
if (test x)
collect (foo x))
Gauche Scheme
(use srfi-13) ;; string-upcase
(filter-map
(lambda (x i) (print i " - " x)
(and (string? x) (string-upcase x)))
'(foo "an" 8 "why")
(lrange 0))
0 - foo
1 - an
2 - 8
3 - why
("AN" "WHY")