Boost logo

Boost :

Subject: Re: [boost] Formal Review: Boost.RangeEx
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-02-28 10:34:24

----- Original Message -----
From: "Giovanni Piero Deretta" <gpderetta_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, February 27, 2009 8:21 PM
Subject: Re: [boost] Formal Review: Boost.RangeEx

On Fri, Feb 27, 2009 at 8:07 PM, vicente.botet <vicente.botet_at_[hidden]> wrote:
> From: "Rogier van Dalen" <rogiervd_at_[hidden]>
>> I think something like zip() would be very useful, but for consistency
>> should probably be spelled zipped().
>> zipped(rng1, rng2) | transformed (unpack(binary_fun())
>> seems more general for iterating through two ranges in parallel.
>> zipped() would also alleviate the need for for_each over two ranges.
> For consistency, why not
> pack(rng1, rng2) | transformed (unpack(binary_fun())
> Vicente

'zip' is a commonly used name for mapping a pair of ranges to ranges
of pairs in other languages; I see no reason not to use it. Also,
boost.iterator already has zip_iterator adapters.

Another (arguably) good name might be transpose, but that is probably
best left for ranges of ranges.

BTW, unpack already exists in boost as fusion::fused.

Unsubscribe & other changes:
As I already say in a preceding post you are right, pack should not be used to replace zipped. 
What about admiting a packet of arguments represented here as (p1, ..., pn) as the input of an adaptor.
    range3 = (range1, range2) | zipped | transformed( unpack(binary_fct) ) 
zipped will be an adaptor that takes an input pack with two elements (arguments) and give a single pack with the zipped view of both ranges. transformed is an adaptor taking a single pack with a range of pairs and return the result of unpacking these pairs and call to a binary function.
I realy think that a generalization of the input and output parameters of these adaptors should be possible.
And what about a 'tee' adaptor to retrieve the result a forward it to the next adaptor, and one 'tie' to retrieve the result.
    (range1, range2)  | concat | tee(range3) | sorted | splited(pred) | tie(range4, range5)
This expression will concatenate the ranges range1 and range2 store the result in range3 sort it and split the sequence respect to a given predicate and store the result in range4 and range5.
How this pack of argument (p1, ..., pn) can be implemented is another question (fusion tuples?)
IMHO this should be out of the scope of the Boost.Range library. I don't think the first release of Boost.Range should come with the operators interface and a deeper analisys about how to chain functors must be done in a separated library.

Boost list run by bdawes at, gregod at, cpdaniel at, john at