public abstract class Value extends java.lang.Object implements java.lang.Comparable<Value>
Value = int + bool + char + triv + ...
+ (Value × Value)
+ (Value → Value)
,
that is, first class Values. Also see Type
.Modifier and Type | Class and Description |
---|---|
static class |
Value.Atomic
|
static class |
Value.Bool
Bool = false | true; also see
Type.BOOL . |
static class |
Value.Char
A Char Value; also see
Type.CHAR . |
static class |
Value.Chars
A Chars (String) Value; also see
Type.CHARS . |
static class |
Value.Cts
|
static class |
Value.Defer
The class of lazy, that is, not yet computed, Deferred Values,
Value.Defer.Exp and Value.Defer.App . |
static class |
Value.Discrete
Discrete Values, such as
Value.Bool , are subclasses of Discrete. |
static class |
Value.Enum
Enum Values, for example, A:DNA; also see
Type.Enum . |
static class |
Value.Inc_Or
Inc_Or t0 t1 = Left t0 | Right t1
| Both t0 t1,
for where one, or both, of v0:t0 and v1:t1 can be present.
|
static class |
Value.Int
Also see
Type.INT . |
static class |
Value.Lambda
Function produced from a
Expression.LambdaExp and an
Environment . |
static class |
Value.List
Linked Lists, a special implementation of the abstract
Value.Option . |
static class |
Value.Maybe
|
static class |
Value.Option
An Option Value has a "tag",
Value.Option.n() , and zero or more
sub-Values, Value.Structured.elt(int) depending on the tag. |
static class |
Value.Real
A class of exact
Value.Cts Values -- those having
. |
static interface |
Value.Scannable
A class that implements Scannable can produce (by toSeries()) a
Series of Values. |
static class |
Value.Structured
|
static class |
Value.Triv
() : . |
static class |
Value.Tuple
The class of heterogeneous k-Tuples, that is pairs, triples,
and so on; also see
Type.Tuple and Vector . |
Constructor and Description |
---|
Value() |
Modifier and Type | Method and Description |
---|---|
double |
AoM()
See
Value.Cts.AoM() . |
Value |
apply(Value v)
This default throws an exception but see
Function.apply(la.la.Value) . |
Value |
bOp(int op,
Value rgt)
Apply binary Operator 'op' to Values 'this' and 'rgt', if implemented
(this default throws an Exception).
|
int |
compareTo(Value v2)
Note, not all Values are actually Comparable.
|
static Value.List.Cell |
cons(Value h,
Value t)
Convenience function returning the List h::t.
|
static Value.Cts |
cts(double x,
double AoM)
Return a
Cts Value representing x±AoM/2. |
Value |
elt(int i)
|
protected java.lang.String |
errMsg(java.lang.String msg)
It has all gone pear-shaped; identify 'this' and 'msg'.
|
protected void |
error(java.lang.String msg)
Throws
RTE(msg) . |
Value |
force()
This default implementation returns 'this' Value, but
the real interest is in
Value.Defer.force() . |
Value.Tuple |
isTuple(int k)
Check that 'this' Value really is a k-Tuple and, if it is,
return it as a Tuple.
|
static Value.Maybe.Just |
just(Value v)
Convenience function, returns new Maybe.Just(v).
|
static void |
main(java.lang.String[] argv)
main() allows Value to be (very slightly) tested in isolation.
|
int |
n()
n() corresponds to an
Int.n() or an
Option.n() etc.; this default throws a
RuntimeException but see Bool.n() , say. |
int |
nElts()
This default throws an exception but see
Value.Structured.nElts() . |
double |
nlAoM()
See
Value.Cts.nlAoM() . |
static Value.Tuple.GP |
pair(Value e0,
Value e1)
pair, a convenience function to make
a
2- . |
void |
print(java.io.PrintStream ps)
Note, evaluation is print driven; this default print(ps) calls
ps.print( and is only used by small,
atomic values; other sub-classes must override it. |
static Value.Tuple.GP |
quad(Value e0,
Value e1,
Value e2,
Value e3)
quad, a convenience function to make
a
4- . |
static Value.Real |
real(double x)
Return an exact
Real Value corresponding to the
double x. |
protected java.lang.RuntimeException |
RTE(java.lang.String msg)
Short for RuntimeException(
errMsg(msg) ) |
java.lang.String |
toString()
|
static Value.Tuple.GP |
triple(Value e0,
Value e1,
Value e2)
triple, a convenience function to make
a
3- . |
static Value.Tuple.GP |
tuple(Value[] vs)
tuple, a convenience function to make
a
k- . |
abstract Type |
type()
Return the
Type of 'this' Value. |
protected java.lang.UnsupportedOperationException |
UOE(java.lang.String msg)
Short for UnsupportedOperationException(
errMsg(msg) ) |
Value |
uOp(int op)
Apply unary Operator 'op' to 'this' Value, if implemented (this
default throws an Exception).
|
double |
x()
|
public static final Value.Triv triv
public static final Value.List nilVal
public static final Value.Bool ffalse
public static final Value.Bool ttrue
public static final Value.Int negOne
public static final Value.Int zero
public static final Value.Int one
public static final Value.Int two
public static final Value.Int three
public static final Value.Int four
public static final Value.Int five
public static final Value.Int six
public static final Value.Int seven
public static final Value.Int eight
public static final Value.Int nine
public static final Value.Int ten
public static final Value.Int C
public static final Value.Real negTenR
public static final Value.Real negOneR
public static final Value.Real zeroR
public static final Value.Real point1
public static final Value.Real point5
public static final Value.Real point01
public static final Value.Real quarter
public static final Value.Real half
public static final Value.Real point9
public static final Value.Real oneR
public static final Value.Real twoR
public static final Value.Real threeR
public static final Value.Real fourR
public static final Value.Real fiveR
public static final Value.Real tenR
public static final Value.Real CR
public static final Value.Real negCR
public static final Value.Real E
public static final Value.Real PI
public static final Value.Real PIby2
public static java.util.Comparator<Value> comparator
comparator.compare(v1, v2)
returns
v1.compareTo(v2)
.
Note, not all Values are actually Comparable.public static final Value.Maybe None
public int compareTo(Value v2)
compareTo
in interface java.lang.Comparable<Value>
public Value uOp(int op)
op
come from Lexical
. Also see bOp(int,Value)
.public Value force()
Value.Defer.force()
.public void print(java.io.PrintStream ps)
ps.print(toString()
)
and is only used by small,
atomic values; other sub-classes must override it.public java.lang.String toString()
printing
of
constants
, and in calls to error(java.lang.String)
.
The result does not necessarily fully specify a large, or
infinite(!), Value. (This default returns the Class Name of 'this'.)
Also see print(ps)
.toString
in class java.lang.Object
public int n()
Int.n()
or an
Option.n()
etc.; this default throws a
RuntimeException but see Bool.n()
, say.
The inclusion of n(), and others, for all Values reduces the need
for casts and also works nicely with Value.Defer
.public double x()
public double AoM()
Value.Cts.AoM()
.
(This default throws a RuntimeException.)public double nlAoM()
Value.Cts.nlAoM()
.
(This default throws a RuntimeException.)public int nElts()
Value.Structured.nElts()
.public Value elt(int i)
public Value apply(Value v)
Function.apply(la.la.Value)
.public static Value.Cts cts(double x, double AoM)
public static Value.Real real(double x)
Real
Value corresponding to the
double x. Continuous data (experimental or observational) cannot
be exact Real, of course.
Also see cts(x,aom)
.public Value.Tuple isTuple(int k)
Tuple tv=v.isTuple(2)
.public static Value.Tuple.GP tuple(Value[] vs)
k-Tuple
.public static Value.Tuple.GP pair(Value e0, Value e1)
2-Tuple
.public static Value.Tuple.GP triple(Value e0, Value e1, Value e2)
3-Tuple
s
.public static Value.Tuple.GP quad(Value e0, Value e1, Value e2, Value e3)
4-Tuple
.public static Value.List.Cell cons(Value h, Value t)
public static Value.Maybe.Just just(Value v)
protected java.lang.String errMsg(java.lang.String msg)
error(str)
,
RTE(str)
, and
UOE(str)
.protected java.lang.RuntimeException RTE(java.lang.String msg)
errMsg(msg)
)protected java.lang.UnsupportedOperationException UOE(java.lang.String msg)
errMsg(msg)
)protected void error(java.lang.String msg)
RTE(msg)
.public static void main(java.lang.String[] argv)