Re: [racket-dev] [Feature Request] for macro #:when clauses should bind their results if asked.

2011-09-06 Thread Eli Barzilay
Just now, Carl Eastlund wrote: > You can also write: > > (for*/list ([(k v) (in-hash ht)] > [res (in-value (f k v))] > #:when res) > res) [It does seem a little too verbose with the 3 mentions of `res', but that's the same kind of verbosity as repeating `x' in: (for/l

Re: [racket-dev] [Feature Request] for macro #:when clauses should bind their results if asked.

2011-09-06 Thread Carl Eastlund
You can also write: (for*/list ([(k v) (in-hash ht)] [res (in-value (f k v))] #:when res) res) The in-value sequence "lifts" values to length-one sequences for just such kinds of bindings. (The above is untested, so may need some fixing.) Carl Eastlund On Tue, Sep 6, 2011 at 2:35 PM,

[racket-dev] [Feature Request] for macro #:when clauses should bind their results if asked.

2011-09-06 Thread J. Ian Johnson
When writing a natural extension to racket/base for hashes, hash-filter-map, I found that what would be the most natural way to write it would look like so: (define (hash-filter-map f ht) (for/list ([(k v) (in-hash ht)] #:when/bind [res (f k v)]) res)) Instead I had to write