[racket] idiomatic way to loop over 1-255 in TR?

From: John Clements (johnbclements at gmail.com)
Date: Wed Feb 18 14:38:51 EST 2015

I want to write this:

(for/list ([b (in-range 256)])
  b)

... and get back a list of bytes.

That is, I want TR to see that the number 256 is one greater than the
largest byte, and therefore that b must be of type byte.  I see that this
dips way too close to undecidability in the general case, so I would
instead perhaps expect to see something like an 'in-bytes-range' form that
is known to produce only bytes.

I looked for such a thing, but didn't find it.  Naturally, I could simply
jam a run-time check in at the top of the body, something like
'ensure-bytes', but it seems unnecessary.

Am I missing something obvious?

Thanks!

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150218/3f593c1c/attachment.html>

Posted on the users mailing list.