You can use for*/list for this situation.
Suppose you essentially want to do a (map f lst),
except that f returns not just the value but a list of zero or more values.
Then do:
(for*/list ((x (in-list lst))
(y (in-list (f x))))
y)
Stephan
On 04/15/2011 09:15 PM, Jay McCarthy wrote:
I turn it into a for/fold or figure how to put the cases I don't want
in the list as #:when for clauses. I think this is a lame solution. I
almost want a C-like "continue" function. Returning an option type
seems like overkill.
Jay
2011/4/15 harsha reddy<[email protected]>:
When using the various versions of for like for/list; I often encounter
situations where the body must not add any value to put into the generated
list (useful when one needs to filter and map simultaneously) or must
generate more than value. I guess the way to do this would be to treat the
result of the body as a list of additions and then concatenate all these
lists. Something similar would be needed for for for/hash(taking care of the
multiple values issue),for/and, for/vector etc.
I just wanted to know, because this seems like a common enough situation,
if there are some standard commands or libraries which implement the
modified versions of these commands.
thanks,
Harsha
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users