<HTML><BODY>I propose to add yet one keyword to for/foldX/derived/break (and so to all for/... syntaxes).<br><br>Reason: <br><br>If one need to filter the results of body before collecting them in list/vector/sum/..., there are two options:<br><br>1. (filter filter-func (for/list ...)) : doubles memory consumption and slower<br>2. (for/list (exprs ...) body ...) => (for/list (exprs ... #:when #t (res (in-value (begin body ...))) #:when (filter-func res)) res). Works, but very clumsy.<br><br>I propose syntax<br>(for/list (exprs ...) body ...) => (for/list (exprs ... #:filter filter-func) body ...) with the same behavior as in 2.<br> <br>Syntax:<br><br>#:filter filter-func = (thunk* #t)<br><br>Expects function with the same number of arguments as the result of for/... body should return values. Applied to results of body, and collected only if filter-func returns #t.<br><br>Implementation:<br><br>Minor changes in for.rkt in (define-syntax (for/foldX/derived stx) ...) and in documentation. If you busy, I may do it myself and make pull request.<br><br>To think about:<br><br>How many values should return filter-func in (for/lists ...). Only one or as many as values of body. I don't know what is more natural.<br><br>--
<br>Roman Klochkov<br></BODY></HTML>