4 ms·
Personally I'm a fan of list comprehension, particularly as implemented by rackets for/list forms. I certainly don't use them for everything, sometimes a plain
by catalogia 6y ago
Personally I'm a fan of list comprehension, particularly as implemented by rackets for/list forms. I certainly don't use them for everything, sometimes a plain old map fits the circumstance better, but I find myself using for/list fairly often. And I don't think it's error prone in the same way that a traditional C-style for loop would be.
https://docs.racket-lang.org/reference/for.html?q=for%2Flist#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2Flist%29%29 https://docs.racket-lang.org/reference/for.html?q=for%2Flist...
> (for/list ([i '(1 2 3)]
[j "abc"]
#:when (odd? i)
[k #(#t #f)])
(list i j k))
'((1 #\a #t) (1 #\a #f) (3 #\c #t) (3 #\c #f))