POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: A test Server Time
1 Oct 2024 00:04:41 EDT (-0400)
  Re: A test  
From: Fredrik Eriksson
Date: 23 Sep 2008 14:07:11
Message: <op.uhx4l9fs7bxctx@e6600>
On Tue, 23 Sep 2008 00:20:42 +0200, Darren New <dne### [at] sanrrcom> wrote:
> Welll..... There's still a bunch of syntax. Template instantiation, <<  
> and >> for I/O, etc.  I mean, compare Haskell add-up-a-list-of-numbers  
> to C++'s. Something like
>    fold (+) my_list
> to something like
>    for (j = std::list.begin(); j != std::list.end(); j = j.next())
>      i += j.value;
> or some such. :-)

'fold' (should probably be 'foldl1') is just a library function, not a  
language primitive. The corresponding C++ library function is  
'std::accumulate'.

   std::accumulate( my_list.begin(), my_list.end(), 0 );



-- 
FE


Post a reply to this message

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