Boost logo

Boost :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2008-03-17 17:35:30


Hi!

Sorry, Eric, if this is a lot of work.
Reject to do it, if you like, or provide only
some of these.

---- Task 1 --------------
Consider I need to flatten a tree into a sum:

template<int I> struct arg {};

proto::terminal<arg<1> >::type a;
proto::terminal<arg<2> >::type b;
proto::terminal<arg<3> >::type c;
proto::terminal<arg<4> >::type d;

a + b + c + d

has type expr<tag::plus, arg2<a tree structure> >

but I need a template function make_flat
taking arbitray expressions and return
expressions of type

expr<sum, args4<all args in the typelist> >

How can I do this in proto?

-----------
Task 2: Next step:

a - b + c should first be transformed into
a + (-b) + c and then transformed into the sum.

Could you please provide full compilable examples?

------

Task 3: Next step:

I want to detect simultaneous occurences of
x and -x and have them dropped from the typelist of my sum.
Please provide an example that detects this for terminals only,
then one which also works for (a*b - a*b) and returns
expr<tag::nil, nulllist> (BTW, is there a nil/null tag in proto?)

---------

Task 4: Write an expand function that for
a*(b+c) returns a type representation a*b+a*c

-----

Markus


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