On 10/08/2015 07:43 PM, Timothee Cour via Digitalmars-d wrote:
also, workarounds involving:
iota(0,256).map!(a=>cast(ubyte)a)
are neither pleasant nor efficient
On Thu, Oct 8, 2015 at 7:41 PM, Timothee Cour <[email protected]>
wrote:
how to do iota(0,256) with ubytes ?
and more generally:
iota with 'end' parameter set to max range of a type.
of course this doesn't work:
auto b=iota(ubyte(0), ubyte(256));
//cannot implicitly convert expression (256) of type int to ubyte
Could we have a function with iota_inclusive that has inclusive bounds for
'end' parameter ?
From an email to a friend earlier this year, without caring much about
performance implications: :)
auto inclusive_iota(T)(T beg, T end)
{
/* Chain the elements of 'iota' (which is end-exclusive)
* and a range containing just the end element
* 'only'. This returns a lazy range. */
return chain(iota(beg, end), only(end));
}
Ali