Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-04-21 13:01:09


On 04/21/2007 12:21 PM, Maurizio Vitale wrote:
[snip]
>
> I'm not sure I understand zeros and ones:
> the value which is interesting is the identity. In the case of additions
> (and ORs) the identity is a 'zero'. In the case of multiplications
> (and ANDs)
> the identity is a 'one'.
> The 'other' value (zero for multiplications and one for additions)
> seems to
> only be of interest for simplifying expressions, rather than being
> logically
> important, but I might miss something here.
>

I believe you do understand, except that both special values
(one and zero) can be used for simplification. Any expression
with 0 is simplified to 0 and any expression with 1 is simplified
to the subexpression without the 1.

Simplification was one application. For example, there's the
following code:

     // sequence rule folds all >>'s together into a list
     // and wraps the result in a composite<> wrapper
     struct ToySpiritSequence
       : as_composite<
             proto::tag::right_shift
           , proto::trans::reverse_fold_to_list<
                 proto::right_shift<ToySpiritGrammar, ToySpiritGrammar>
>
>
     {};

in the proto/test/toysprit2.cpp file. I'm just guessing, but I'd think
this folding could be accompanied by simplification based on the above
rules.


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