>> Now what happens if you want to only process elements having some
>> arbitrary property? (E.g., only the odd numbers.)
>
> I make the function take a functor which tells which elements to process.
> This is a standard technique in C++.
Right. And now what if the elements to process depends on the
surrounding context and you have to make several passes of the list to
identify them?
We're missing my point though. My point is that you can't write a
specialised implementation for every possible combination of list
processing operations. But with stream fusion, the compiler can generate
those for you - and yet the source code stays easily readable and
modifiably.
> There are algorithms for which linked lists are the most efficient
> data container. You still don't want to be needlessly copying the elements
> around, though.
Agreed.
This is why people have spent years doing research and coming up with
sophisticated optimisation techniques. :-)
Post a reply to this message
|