[racket-dev] sequence syntax for (mlist #t #f …) ?
On Jun 21, 2012, at 1:34 AM, Robby Findler wrote:
> I usually in-naturals and zero? to do this.
Ah! That's nice. I can use that.
>
> I see that one example (that I didn't write is in base-render.rkt
>
> (define/public (render-nested-flow i part ri starting-item?)
> (for/list ([b (in-list (nested-flow-blocks i))]
> [pos (in-naturals)])
> (render-block b part ri (and starting-item? (zero? pos)))))
>
> Robby
>
> On Thu, Jun 21, 2012 at 3:24 AM, Eli Barzilay <eli at barzilay.org> wrote:
>> An hour and a half ago, John Clements wrote:
>>> Reality check before I do something dumb and re-invent the wheel:
>>>
>>> I often want to write a for loop where the first element is treated
>>> specially. In such cases, it would be nice to have a sequence that
>>> had a #t and then an infinite number of #f's, so I could write
>>>
>>> (for ([s my-sequence] [first? <true-then-always-falses>]) …)
>>
>> What are you using it for? (Out of curiosity, I wonder if there's any
>> need for this that doesn't fall under what `add-between' does.)
Nothing unusual; I'm writing newlines in between rendered expressions in the stepper. I don't think an add-between would make for more readable code in this case, but it's a related use.
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120621/2e7ccfe2/attachment.p7s>