|
|
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> fold goes from yadda.begin() to yadda.end(). If you don't want to do
>> that, use a different function. Or write it more iteratively, so to
>> speak. Think about your C++ implementation of fold - you would have to
>> copy the list there too if you wanted to use that on a subset.
>
> Or I could simply make an overloaded version of the fold function which
> takes an iterator range.
Which is what I was suggesting be done with Haskell, when I said "write
a more iterative version". Pass in a start index and a length, walk down
the list "start" elements, apply the operator to "length" elements,
return the result. If you don't want to copy the list, don't separate
out the function of copying the subset from the function of applying the
operator. (I don't know, Haskell might even be smart enough to lazily do
the Right Thing there even if you do it naively.)
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
|