[racket] generating 0 or more than 1 additions in the body of for/list, for/vector, for/hash

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Apr 15 15:30:48 EDT 2011

I thought of something else you can do

(sequence->list
 (in-generator
  (for ([e (in-list l)])
   (if (f e)
       (if ...
          (begin (yield 1) (yield 2))
          (yield 3))
       (void)))))

I've done that a few times

Jay

2011/4/15 Jay McCarthy <jay.mccarthy at gmail.com>:
> 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 <wembdnow at gmail.com>:
>> 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
>>
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93



Posted on the users mailing list.