Why is std.algorithm so complicated to use?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jul 10 11:12:43 PDT 2012


On 7/10/12 2:02 PM, Simen Kjaeraas wrote:
> On Tue, 10 Jul 2012 17:21:14 +0200, Christophe Travert
> <travert at phare.normalesup.org> wrote:
>
>> "Simen Kjaeraas" , dans le message (digitalmars.D:171678), a écrit :
>>>> Well, I haven't been able to use a single function from std.algorithm
>>>> without adding a lot of calls to "array" or "to!(string)". I think the
>>>> things I'm trying to do seems trivial and quite common. I'm I
>>>> overrating
>>>> std.algorithm or does it not fit my needs?
>>>>
>>>
>>> bearophile (who else? :p) has suggested the addition of eager and
>>> in-place
>>> versions of some ranges, and I think he has a very good point.
>>
>> That would have been useful before UFSC.
>> Now, writing .array() at the end of an algorithm call is not a pain.
>>
>> int[] = [1, 2, 2, 3].uniq().map!toString().array();
>>
>
> Please tell me how that is in-place.

Let's say it doesn't perform unnecessary allocations. It's like you'd 
create the array ["1", "2", "3"] from the array [1, 2, 2, 3] using a 
loop and a couple of state variables.

Andrei




More information about the Digitalmars-d mailing list