Stupid little iota of an idea

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Feb 12 18:00:41 PST 2011


On 2/12/11, Peter Alexander <peter.alexander.au at gmail.com> wrote:
> On 12/02/11 9:16 PM, Nick Sabalausky wrote:
>> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org>  wrote in message
>>> Not all users dislike iota, and besides arguments ad populum are
>>> fallacious. Iota rocks. But have at it - vote away, and I'll be glad if a
>>> better name for iota comes about.
>>>
>>
>> I vote "a..b:c" and "step"
>
> As Michel pointed out, a..b:c is ambiguous.
>
> auto foo = [ 1..10 : 2, 2..20 : 3 ];
>
> Is foo an AA of ranges to ints, or an array of stepped ranges?
>

array of stepped ranges:
auto foo = [[1..10 : 2], [2..20 : 3]];
output:
[[1, 3, 5, 7, 9], [2, 5, 8, 11, 14, 17]]

AA of ranges to ints:
auto foo = [[1..10] : 2, [2..20] : 3];
output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]:2
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]:3


iota vs new syntax:

    auto iot1 = [iota(1,10,2), iota(2, 20, 3)];     // array
    auto iot2 = [iota(1,10) : 2, iota(2, 20) : 3];  // AA

    auto syn1 = [[1..10 : 2], [2..20 : 3]];    // array
    auto syn2 = [[1..10] : 2, [2..20] : 3];    // AA


More information about the Digitalmars-d mailing list