Boost logo

Boost Users :

From: Marco Correia (mvc_at_[hidden])
Date: 2006-02-03 19:32:09


Thanks!

Today I managed to get a little bit further, let me tell you where I am.

First I aliased every symbol of the alphabet as an integer.

#define A 1
#define B 2
...

Then I guess there are two options:

1)

#define NOT_EQ(s,E1,E2) \
        BOOST_PP_NOT_EQUAL(E1,E2)

#define REMOVE_ALL(Elem,Seq) \
        BOOST_PP_SEQ_FILTER(NOT_EQ, Elem, Seq)

#define REMOVE_ELEM(s,Seq,Elem) REMOVE_ALL(Elem,Seq)(Elem)

#define REMOVE_DUPLICATES(Seq) \
        BOOST_PP_SEQ_FOLD_LEFT(REMOVE_ELEM, Seq, Seq)

This starts with the full sequence, and for each element, removes all
occurences and add it in the end.

2)

The other option is similar but instead of starting with the full sequence and
remove each element, it starts with an empty sequence and adds each element
if it is not already there (kind of insertion sort but without sorting).

I think the solution 1) is faster, but I confess it's only an intuition :)

Do you see any other way, more efficient than this?

Thanks a lot for trying to help!

Marco

On Friday 03 February 2006 22:48, you wrote:
> Hi Marco,
>
> I just say this post now, so I'll get back to it after I get home from
> work. I the pp-lib can help you with this.
>
> Regards,
> Paul Mensonides
>
> > -----Original Message-----
> > From: boost-users-bounces_at_[hidden]
> > [mailto:boost-users-bounces_at_[hidden]] On Behalf Of
> > Marco Correia
> >
> > I would like to ask if there is a way boost::preprocessor may
> > be used to solve the following problem:
> >
> > The problem is to define a macro that expands to the
> > concatenation of their arguments, without duplicates. The
> > arguments are symbols belonging to a known alphabet.

-- 
Marco Correia <mvc_at_[hidden]>

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