[racket-dev] sequence syntax for (mlist #t #f …) ?
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>]) …)
Hey, no problem! Mutable lists can be used as sequences. But--and here I feel as though my brains have suddenly vanished--I can't think of the nice short way to write
(mlist #t #f …)
I'd be sort of okay with writing
(mcons #t #0=(mcons #f #0#))
… but that's not allowed, either.
Yes, of course I can do it the ugly way:
(define p1 (mcons #f 'bogus))
(set-mcdr! p1 p1)
(define true-then-falses (mcons #t p1))
Of course, it would be unbelievably easy to write an mlist syntactic form, but there *must* be a form that's been around for 150 years that already does this.
Sorry to have forgotten Scheme,
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/20120620/3928647b/attachment.p7s>