+} // anon namespace
+
+void write(MathData const & dat, WriteStream & wi)
+{
+ MathData ar = dat;
+ extractStrings(ar);
+ wi.firstitem() = true;
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it) {
+ (*it)->write(wi);
+ wi.firstitem() = false;
+ }
+}
+
+
+void normalize(MathData const & ar, NormalStream & os)
+{
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->normalize(os);
+}
+
+
+void octave(MathData const & dat, OctaveStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, OCTAVE);
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->octave(os);
+}
+
+
+void maple(MathData const & dat, MapleStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, MAPLE);
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->maple(os);
+}
+
+
+void maxima(MathData const & dat, MaximaStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, MAXIMA);
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->maxima(os);
+}
+
+
+void mathematica(MathData const & dat, MathematicaStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, MATHEMATICA);
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->mathematica(os);
+}
+
+
+void mathmlize(MathData const & dat, MathStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, MATHML);
+ if (ar.size() == 0)
+ os << "<mrow/>";
+ else if (ar.size() == 1)
+ os << ar.front();
+ else {
+ os << MTag("mrow");
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->mathmlize(os);
+ os << ETag("mrow");
+ }
+}
+
+// convert this inset somehow to a number
+bool extractNumber(MathData const & ar, int & i)
+{
+ idocstringstream is(charSequence(ar.begin(), ar.end()));
+ is >> i;
+ return is;
+}
+
+
+bool extractNumber(MathData const & ar, double & d)
+{
+ idocstringstream is(charSequence(ar.begin(), ar.end()));
+ is >> d;
+ return is;
+}
+