B. Pym
2024-09-08 12:06:16 UTC
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 Schemeunder 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))
(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")