Boost logo

Boost Users :

Subject: Re: [Boost-users] Odd limitation in Fusion design ?
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-07-08 00:29:58


On 7/8/10 8:40 AM, John Dlugosz wrote:
> I see that the "Cons" sequence is Forward-only. reverse_view requires a Bidirectional
> sequence, at least. The for_each iteration function goes forward.
>
> However, hand-written recursive loop on a cons-like thing can do stuff before and other
> stuff after the recursive call to the cdr portion. Putting stuff "after" will give a
> reversed processing. So, in general, a reversed_for_each is not out of the question,
> and can be specialized for Cons when the general form of iterating backwards does not
> work.
>
> I also ponder that a more general form that indeed does stuff before AND other stuff
> after recursing the tail would be a useful addition. It might actually perform one
> operation iterating forward, then perform the other operation iterating backward back
> to the beginning; or use recursion; depending on the nature of the container.

That is an interesting thought. Contributions are always welcome.
Algorithms can indeed be applied reversibly in Fusion, not only
for cons lists but all fusion ranges in general (I think). The
stack holds all the iterators anyway!

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net