POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: A test Server Time
30 Sep 2024 19:31:44 EDT (-0400)
  Re: A test  
From: Darren New
Date: 24 Sep 2008 11:33:56
Message: <48da5de4$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.