Boost logo

Boost :

Subject: Re: [boost] [fusion] Any chance we can incorporate more folds?
From: David Sankel (camior_at_[hidden])
Date: 2010-08-20 20:13:44


On Fri, Aug 20, 2010 at 6:43 PM, Stefan Strasser <strasser_at_[hidden]>wrote:

> Zitat von David Sankel <camior_at_[hidden]>:
>
> I've implemented, in particular, foldr1:
>>
>> template<
>> typename Sequence,
>> typename State,
>> typename F
>>
>>>
>>> typename result_of::foldr1<Sequence, F>::type foldr1(
>> Sequence& seq, F const& f);
>>
>> Semantics:
>>
>> Equivalent to f(....f(f(e1,e2),e3)...) where e1 ...eN are the elements
>> of seq.
>>
>
> isn't this equivalent to
> fold(pop_front(seq),front(seq),f) ?

Almost...

fold(pop_front(seq),front(seq), flip( f ) )

where flip returns a version of f with swapped arguments.

David

-- 
David Sankel
Sankel Software
www.sankelsoftware.com
585 617 4748 (Office)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk