These are the functions for creating a RingElem
from a string
or an istream
.
Let
str
be a string
,
in
be a string
or istream
(e.g. reading from file),
and R
any ring
.
They both return the expression read from in
and evaluated in R
.
RingElem(R, str)
-- RingElem
constructor, same as ReadExpr(R, str)
ReadExpr(R, in)
-- keeps reading to the end of input (so it's
convenient for reading from a string)
ReadExprSemicolon(R, in)
-- stops at the semicolon (convenient for reading from file or standard input)
RingElems(R, in)
-- returns a vector<RingElem>
of the comma-separated list of RingElem
written in file/string in
RingElemVec(R, in)
-- returns a vector<RingElem>
of the comma-separated list of RingElem
inside square brackets written in file/string in
Recognized operations in the string are:
+ - * / ^ ()
The expression may contain integer constants or decimals (which are read
as exact rational numbers, e.g. 1.25
is read the same as (5/4)
).
The expression may contain symbols (any indices are placed after the symbol
head inside square brackets, and separated by commas).
Code is so nice it does not need any documentation! ;-)
Potentially ambiguous expressions such as 1/2/3
are accepted (without any
warning message), and interpreted as (1/2)/3
.
2019
RingElems
for reading a vector
2016
2014