how to do iota(0,256) with ubytes ? (cf need for iotaInclusive)

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 11 08:34:34 PDT 2015


On Sunday, 11 October 2015 at 13:58:24 UTC, Temtaime wrote:
> On Friday, 9 October 2015 at 07:20:43 UTC, John Colvin wrote:
>> On Friday, 9 October 2015 at 02:41:50 UTC, Timothee Cour 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 ?
>>
>> A bounds parameter would be nice, like in std.random.uniform.
>>
>>
>> For anyone googling for a solution to this, here's a 
>> workaround:
>>
>> auto b = iota(0, 256).map!"cast(ubyte)a";
>>
>> Unfortunately this doesn't scale to iterating over all values 
>> of long or ulong.
>
> Do not use string lambdas. It will be deprecated.

I'm pretty sure that's not going to happen. Could you point me to 
something that supports that statement? I know there a few people 
who *want* them to be deprecated/removed, but that's a very 
different matter from "will be deprecated".


More information about the Digitalmars-d mailing list