DMD 0.170 release
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sun Oct 29 10:09:45 PST 2006
Chris Nicholson-Sauls wrote:
> Bruno Medeiros wrote:
>> Sean Kelly wrote:
>>
>>> Bruno Medeiros wrote:
>>>
>>>>
>>>> Scrap that, duh. Non-ordered 'iteration' is, kinda like you said,
>>>> without breaks or gotos, and thus applied to all elements. So one
>>>> can use regular functions with delegate parameters to do this
>>>> 'iteration'. These non-ordered, complete 'iterations' are actually
>>>> the list/collection 'comprehensions'
>>>> (http://www.digitalmars.com/d/archives/digitalmars/D/39313.html ,
>>>> which we knew already, but didn't remember?) which are very easy to
>>>> parallelize (think Google MapReduce). Doesn't this solve the issue,
>>>> in quite cleaner syntax and semantics?
>>>
>>>
>>> It's a cool idea:
>>>
>>> x = vector[ (int t){return t>5;} ]; // subset of vector
>>> vector[] = (inout int x) { x += 100; }; // update all members of vector
>>>
>>> However, the second example above seems like it wouldn't work for an
>>> array of delegates, since this is a legal 'copy' syntax.
>>>
>>>
>>> Sean
>>
>>
>> Do you have something against methods?... :p
>>
>> x = vector.filter( (int t){return t>5;} ); // subset of vector
>> vector.apply( (inout int x) { x += 100;} ); // update all members
>>
>>
>
> Looks good to me. I do have .filter implemented in CashewUtils, and
> might just add a ..apply now that you mention it.
>
> -- Chris Nicholson-Sauls
If that's so, then you should check for Oskar Linde's array utility
code. He's the one I first recall talking about array (list)
comprehensions in D, and he posted quite some arrays lib code with that,
but unfortunately I don't know exactly which post was it, so I can't
find it.
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d-announce
mailing list