
% Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     - Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     - Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the
%       distribution.
%
%     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES-- LOSS OF USE, DATA, OR
% PROFITS-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



%%
%% fr2.htex
%%
%% FactoredFunctions2
%%

The \spadtype{FactoredFunctions2} package implements one operation,
\spadfunFrom{map}{FactoredFunctions2}, for applying an operation to every
base in a factored object and to the unit.
\xtc{
}{
\spadcommand{double(x) == x + x \bound{double}}
}
\xtc{
}{
\spadcommand{f := factor(720) \bound{f}}
}
\xtc{
Actually, the \spadfunFrom{map}{FactoredFunctions2} operation used
in this example comes from \spadtype{Factored} itself, since
\userfun{double} takes an integer argument and returns an integer
result.
}{
\spadcommand{map(double,f) \free{f}\free{double}}
}
\xtc{
If we want to use an operation that returns an object that has a type
different from the operation's argument,
the \spadfunFrom{map}{FactoredFunctions2} in \spadtype{Factored}
cannot be used and we use the one in \spadtype{FactoredFunctions2}.
}{
\spadcommand{makePoly(b) == x + b \bound{makePoly}}
}
\xtc{
In fact, the ``2'' in the name of the package means that we might
be using factored objects of two different types.
}{
\spadcommand{g := map(makePoly,f) \free{f}\free{makePoly}\bound{g}}
}
It is important to note that both versions of \spadfunFrom{map}{FactoredFunctions2}
destroy any information known about the bases (the fact that they are prime,
for instance).
\xtc{
The flags for each base are set to ``nil'' in the object returned
by \spadfunFrom{map}{FactoredFunctions2}.
}{
\spadcommand{nthFlag(g,1) \free{g}}
}

For more information about factored objects and their use, see
\xmpref{Factored} and
\spadref{ugProblemGalois}.
