[racket] for/hash and for/list: adding nothing, adding more than one thing
Dear All,
I've recently started hacking Racket again, and am loving the for/*
constructs.
Awesome stuff. However, I have two questions about for/hash.
(1) How can I *not* add a hash entry for a given iteration?
When I use for/list, can I abuse the nature of empty and append* (I cringe
as I write this):
(append* (for/list ([i '(1 2 3 4 5)])
(cond [(even? i) (list (* i 100))]
[else empty])))
Surely there is a better way to do this for for/list, and a way in general
for for/hash?
(2) How can I add multiple entries (that is, >1 key-value pair) in a given
iteration?
Again, using for/list I can cheat via append*:
(append* (for/list ([i '(1 2 3 4 5)])
(list (* i 100) (* i 200))))
What's the right way to do this in for/hash?
Thanks,
- Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130321/b437d2a4/attachment.html>