Enum BuiltIn
- All Implemented Interfaces:
Serializable,Comparable<BuiltIn>,java.lang.constant.Constable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceCallback used when defining a datatype.static classBuilt-in structure.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFunction "abs", of type "int → int".Literal "false", of type "bool".Operator "General.op o", of type "(β → γ) * (α → β) → α → γ"Function "General.ignore", of type "α → unit".Function "Interact.use" of type "string → unit"Function "List.all", of type "(α → bool) → α list → bool".Function "List.app", of type "(α → unit) → α list → unit".Function "List.at", of type "α list * α list → α list".Function "List.collate", of type "(α * α → order) → α list * α list → order".Function "List.concat", of type "α list list → α list".Function "List.drop", of type "α list * int → α list".Function "List.exists", of type "(α → bool) → α list → bool".Function "List.filter", of type "(α → bool) → α list → α list".Function "List.find", of type "(α → bool) → α list → α option".Function "List.foldl", of type "(α * β → β) → β → α list → β".Function "List.foldr", of type "(α * β → β) → β → α list → β".Function "List.getItem", of type "α list → (α * α list) option".Function "List.hd", of type "α list → α".Function "List.last", of type "α list → α".Function "List.length", of type "α list → int".Function "List.map", of type "(α → β) → α list → β list".Function "List.mapPartial", of type "(α → β option) → α list → β list".Constant "List.nil", of type "α list".Function "List.nth", of type "α list * int → α".Function "List.null", of type "α list → bool".Operator "List.op @", of type "α list * α list → α list".Function "List.partition", of type "(α → bool) → α list → α list * α list".Function "List.rev", of type "α list → α list".Function "List.revAppend", of type "α list * α list → α list".Function "List.tabulate", of type "int * (int → α) → α list".Function "List.take", of type "α list * int → α list".Function "List.tl", of type "α list → α list".Function "Math.acos", of type "real → real".Function "Math.asin", of type "real → real".Function "Math.atan", of type "real → real".Function "Math.atan2", of type "real *real → real".Function "Math.cos", of type "real → real".Function "Math.cosh", of type "real → real".Constant "Math.e", of type "real", is the base e (2.718281828...) of the natural logarithm.Function "Math.exp", of type "real → real".Function "Math.ln", of type "real → real".Function "Math.log10", of type "real → real".Constant "Math.pi", of type "real" is the constant pi (3.141592653...).Function "Math.pow", of type "real * real → real".Function "Math.sin", of type "real → real".Function "Math.sinh", of type "real → real".Function "Math.sqrt", of type "real → real".Function "Math.tan", of type "real → real".Function "Math.tanh", of type "real → real".Function "not", of type "bool → bool".Infix operator "^", of type "string * string → string".Infix operator "::" (list cons), of type "α * α list → α list".Infix operator "div", of type "int * int → int".Infix operator "/", of type "α * α → α" (where α must be numeric).Infix operator "elem", of type "α * α list; → bool".Infix operator "=", of type "α * α → bool".Infix operator "except", of type "α list * α list → α list".Infix operator "≥", of type "α * α → bool" (where α must be comparable).Infix operator ">", of type "α * α → bool" (where α must be comparable).Infix operator "intersect", of type "α list * α list → α list".Infix operator "≤", of type "α * α → bool" (where α must be comparable).Infix operator "<", of type "α * α → bool" (where α must be comparable).Infix operator "-", of type "α * α → α" (where α must be numeric).Infix operator "mod", of type "int * int → int".Infix operator "<>", of type "α * α → bool".Prefix operator "~", of type "α → α" (where α must be numeric).Infix operator "notelem", of type "α * α list; → bool".Infix operator "+", of type "α * α → α" (where α must be numeric).Infix operator "-", of type "α * α → α" (where α must be numeric).Infix operator "union", of type "α list * α list → α list".Function "Option.app", of type "(α → unit) → α option → unit".Function "Option.compose", of type "(α → β) * (γ → α option) → γ → β option".Function "Option.composePartial", of type "(α → β option) * (γ → α option) → γ → β option".Function "Option.filter", of type "(α → bool) → α → α option".Function "Option.getOpt", of type "α option * α → α".Function "Option.isSome", of type "α option → bool".Function "Option.join", of type "α option option → α option".Function "Option.map", of type "(α → β) → α option → β option".Function "Option.mapPartial", of type "(α → β option) → α option → β option".Function "Option.valOf", of type "α option → α".Function "Real.abs", of type "real → real".Function "Real.ceil", of type "real → int".Function "Real.checkFloat", of type "real → real".Function "Real.compare", of type "real * real → real".Function "Real.copySign", of type "real * real → real".Function "Real.floor", of type "real → int".Function "Real.fromInt", of type "int → real".Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns{man, exp}, wheremanandexpare the mantissa and exponent of r, respectively.Function "Real.fromString s", of type "string → real option", scans arealvalue from astring.Function "Real.isFinite", of type "real → bool".Function "Real.isNan", of type "real → bool".Function "Real.isNormal", of type "real → bool".Function "Real.max", of type "real * real → real".Constant "Real.maxFinite", of type "real".Function "Real.min", of type "real * real → real".Constant "Real.minNormalPos", of type "real".Constant "Real.minPos", of type "real".Constant "Real.negInf", of type "real".Constant "Real.posInf", of type "real".Constant "Real.precision", of type "int".Constant "Real.radix", of type "int".Function "Real.realCeil", of type "real → real".Function "Real.realFloor", of type "real → real".Function "Real.realMod", of type "real * real → real".Function "Real.realRound", of type "real → real".Function "Real.realTrunc", of type "real → real".Function "Real.rem", of type "real * real → real".Function "Real.round", of type "real → int".Function "Real.sameSign", of type "real * real → bool".Function "Real.sign", of type "real → int".Function "Real.signBit", of type "real → bool".Function "Real.split", of type "real → {frac:real, whole:real}".Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns{man, exp}, wheremanandexpare the mantissa and exponent of r, respectively.Function "Real.toString", of type "real → string".Function "Real.trunc", of type "real → int".Function "Real.unordered", of type "real * real → bool".Function "Relational.count", aka "count", of type "int list → int".Function "Relational.exists", aka "exists", of type "α list → bool".Function "Relational.iterate", aka "iterate", of type "α list → (α list → α list → α list) → α list".Function "Relational.max", aka "max", of type "α list → α" (where α must be comparable).Function "Relational.min", aka "min", of type "α list → α" (where α must be comparable).Function "Relational.notExists", aka "notExists", of type "α list → bool".Function "Relational.only", aka "only", of type "α list → α".Function "Relational.sum", aka "sum", of type "α list → α" (where α must be numeric).Function "String.concat", of type "string list → string".Function "String.concatWith", of type "string → string list → string".Function "String.explode", of type "string → char list".Function "String.extract", of type "string * int * int option → string".Function "String.implode", of type "char list → string".Function "String.isPrefix", of type "string → string → bool".Function "String.isSubstring", of type "string → string → bool".Function "String.isSuffix", of type "string → string → bool".Function "String.map", of type "(char → char) → string → string".Constant "String.maxSize", of type "int".Function "String.size", of type "string → int".Function "String.str", of type "char → string".Function "String.sub", of type "string * int → char".Function "String.substring", of type "string * int * int → string".Function "String.translate", of type "(char → string) → string → string".Function "Sys.env", aka "env", of type "unit → string list".Value "Sys.file", aka "file", of type "{...}" (partial record).Function "Sys.plan", aka "plan", of type "unit → string".Function "Sys.set", aka "set", of type "string * α → unit".Function "Sys.show", aka "set", of type "string → string option".Function "Sys.unset", aka "unset", of type "string → unit".Literal "true", of type "bool".Function "Vector.all" of type "(α → bool) → α vector → bool".Function "Vector.app" of type "(α → unit) → α vector → unit".Function "Vector.appi" of type "(int * α → unit) → α vector → unit".Function "Vector.collate" of type "(α * α → order) → α vector * α vector → order".Function "Vector.concat" of type "α vector list → α vector".Function "Vector.exists" of type "(α → bool) → α vector → bool".Function "Vector.find" of type "(α → bool) → α vector → α option".Function "Vector.findi" of type "(int * α → bool) → α vector → (int * α) option".Function "Vector.foldl" of type "(α * β → β) → β → α vector → β".Function "Vector.foldli" of type "(int * α * β → β) → β → α vector → β".Function "Vector.foldr" of type "(α * β → β) → β → α vector → β".Function "Vector.foldri" of type "(int * α * β → β) → β → α vector → β".Function "Vector.fromList" of type "α list → α vector".Function "Vector.length" of type "α vector → int".Function "Vector.map" of type "(α → β) → α vector → β vector".Function "Vector.mapi" of type "(int * α → β) → α vector → β vector".Constant "Vector.maxLen" of type "int".Function "Vector.sub" of type "α vector * int → α".Function "Vector.tabulate" of type "int * (int → α) → α vector".Function "Vector.update" of type "α vector * int * α → α vector".Internal operator "andalso", of type "bool * bool → bool".Internal divide operator "/", of type "int * int → int".Internal divide operator "/", of type "real * real → real".Internal type extent, e.g.Internal list constructor, e.g.Internal minus operator "-", of type "int * int → int".Internal minus operator "-", of type "real * real → real".Internal unary negation operator "~", of type "int → int".Internal unary negation operator "~", of type "real → real".Internal operator "orelse", of type "bool * bool → bool".Internal plus operator "+", of type "int * int → int".Internal plus operator "+", of type "real * real → real".Internal relational sum operator "sum", of type "int * int → int".Internal relational sum operator "sum", of type "real * real → real".Internal times operator "*", of type "int * int → int".Internal times operator "*", of type "real * real → real". -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringAn alias, or null.static final SortedMap<String, BuiltIn.Structure> final StringUnqualified name, e.g.private final PrimitiveTypeComputes a value for a particular session.final StringName of the structure (e.g.final Function<TypeSystem, Type> Derives a type, in a particular type system, for this constant or function. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBuiltIn(@Nullable String structure, String mlName, @Nullable String alias, Function<TypeSystem, Type> typeFunction) privateBuiltIn(@Nullable String structure, String mlName, @Nullable String alias, Function<TypeSystem, Type> typeFunction, @Nullable PrimitiveType preferredType, @Nullable Function<Session, Object> sessionValue) privateprivateBuiltIn(@Nullable String structure, String mlName, PrimitiveType preferredType, Function<TypeSystem, Type> typeFunction) -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddataTypes(TypeSystem typeSystem, List<Binding> bindings) Defines built-indatatypeandeqtypeinstances, e.g.private static voiddefineDataType(TypeSystem ts, List<Binding> bindings, String name, boolean internal, int varCount, UnaryOperator<BuiltIn.DataTypeHelper> transform) private static voiddefineEqType(TypeSystem ts, String name, int varCount) static voidforEach(TypeSystem typeSystem, BiConsumer<BuiltIn, Type> consumer) Calls a consumer once per value.static voidforEachStructure(TypeSystem typeSystem, BiConsumer<BuiltIn.Structure, Type> consumer) Calls a consumer once per structure.voidprefer(Consumer<PrimitiveType> consumer) reverse()Returns the reverse comparison operator, R, such that "x this y" if and only if "y R x".static BuiltInReturns the enum constant of this type with the specified name.static BuiltIn[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
TRUE
Literal "true", of type "bool". -
FALSE
Literal "false", of type "bool". -
NOT
Function "not", of type "bool → bool". -
ABS
Function "abs", of type "int → int". -
OP_CARET
Infix operator "^", of type "string * string → string". -
OP_EXCEPT
Infix operator "except", of type "α list * α list → α list". -
OP_INTERSECT
Infix operator "intersect", of type "α list * α list → α list". -
OP_UNION
Infix operator "union", of type "α list * α list → α list". -
OP_CONS
Infix operator "::" (list cons), of type "α * α list → α list". -
OP_DIV
Infix operator "div", of type "int * int → int". -
OP_DIVIDE
Infix operator "/", of type "α * α → α" (where α must be numeric). -
OP_EQ
Infix operator "=", of type "α * α → bool". -
OP_GE
Infix operator "≥", of type "α * α → bool" (where α must be comparable). -
OP_GT
Infix operator ">", of type "α * α → bool" (where α must be comparable). -
OP_LE
Infix operator "≤", of type "α * α → bool" (where α must be comparable). -
OP_LT
Infix operator "<", of type "α * α → bool" (where α must be comparable). -
OP_NE
Infix operator "<>", of type "α * α → bool". -
OP_ELEM
Infix operator "elem", of type "α * α list; → bool". -
OP_NOT_ELEM
Infix operator "notelem", of type "α * α list; → bool". -
OP_MINUS
Infix operator "-", of type "α * α → α" (where α must be numeric). -
OP_MOD
Infix operator "mod", of type "int * int → int". -
OP_PLUS
Infix operator "+", of type "α * α → α" (where α must be numeric). -
OP_NEGATE
Prefix operator "~", of type "α → α" (where α must be numeric). -
OP_TIMES
Infix operator "-", of type "α * α → α" (where α must be numeric). -
IGNORE
Function "General.ignore", of type "α → unit". -
GENERAL_OP_O
Operator "General.op o", of type "(β → γ) * (α → β) → α → γ""f o g" is the function composition of "f" and "g". Thus, "(f o g) a" is equivalent to "f (g a)".
-
INTERACT_USE
Function "Interact.use" of type "string → unit""use f" loads source text from the file named `f`.
-
STRING_MAX_SIZE
Constant "String.maxSize", of type "int"."The longest allowed size of a string".
-
STRING_SIZE
Function "String.size", of type "string → int"."size s" returns |s|, the number of characters in string s.
-
STRING_SUB
Function "String.sub", of type "string * int → char"."sub (s, i)" returns the
ith character of s, counting from zero. This raisesSubscriptif i < 0 or |s| ≤ i. -
STRING_EXTRACT
Function "String.extract", of type "string * int * int option → string"."extract (s, i, NONE)" and "extract (s, i, SOME j)" return substrings of
s. The first returns the substring ofsfrom theith character to the end of the string, i.e., the strings[i..|s|-1]. This raisesSubscriptifi < 0or|s| < i.The second form returns the substring of size
jstarting at indexi, i.e., thestring s[i..i+j-1]. It raisesSubscriptifi < 0orj < 0or|s| < i + j. Note that, if defined, extract returns the empty string wheni = |s|. -
STRING_SUBSTRING
Function "String.substring", of type "string * int * int → string"."substring (s, i, j)" returns the substring s[i..i+j-1], i.e., the substring of size j starting at index i. This is equivalent to extract(s, i, SOME j).
-
STRING_CONCAT
Function "String.concat", of type "string list → string"."concat l" is the concatenation of all the strings in l. This raises
Sizeif the sum of all the sizes is greater than maxSize. -
STRING_CONCAT_WITH
Function "String.concatWith", of type "string → string list → string"."concatWith s l" returns the concatenation of the strings in the list l using the string s as a separator. This raises
Sizeif the size of the resulting string would be greater than maxSize. -
STRING_STR
Function "String.str", of type "char → string"."str c" is the string of size one containing the character c.
-
STRING_IMPLODE
Function "String.implode", of type "char list → string"."implode l" generates the string containing the characters in the list l. This is equivalent to
concat (List.map str l). This raisesSizeif the resulting string would have size greater than maxSize. -
STRING_EXPLODE
Function "String.explode", of type "string → char list"."explode s" is the list of characters in the string s.
-
STRING_MAP
Function "String.map", of type "(char → char) → string → string"."map f s" applies f to each element of s from left to right, returning the resulting string. It is equivalent to
implode(List.map f (explode s)). -
STRING_TRANSLATE
Function "String.translate", of type "(char → string) → string → string"."translate f s" returns the string generated from s by mapping each character in s by f. It is equivalent to {code concat(List.map f (explode s))}.
-
STRING_IS_PREFIX
Function "String.isPrefix", of type "string → string → bool"."isPrefix s1 s2" returns true if the string s1 is a prefix of the string s2. Note that the empty string is a prefix of any string, and that a string is a prefix of itself.
-
STRING_IS_SUBSTRING
Function "String.isSubstring", of type "string → string → bool"."isSubstring s1 s2" returns true if the string s1 is a substring of the string s2. Note that the empty string is a substring of any string, and that a string is a substring of itself.
-
STRING_IS_SUFFIX
Function "String.isSuffix", of type "string → string → bool"."isSuffix s1 s2" returns true if the string s1 is a suffix of the string s2. Note that the empty string is a suffix of any string, and that a string is a suffix of itself.
-
LIST_NIL
Constant "List.nil", of type "α list"."nil" is the empty list.
-
LIST_NULL
Function "List.null", of type "α list → bool"."null l" returns true if the list l is empty.
-
LIST_LENGTH
Function "List.length", of type "α list → int"."length l" returns the number of elements in the list l.
-
LIST_AT
Function "List.at", of type "α list * α list → α list"."l1 @ l2" returns the list that is the concatenation of l1 and l2.
-
LIST_OP_AT
Operator "List.op @", of type "α list * α list → α list"."l1 @ l2" returns the list that is the concatenation of l1 and l2.
-
LIST_HD
Function "List.hd", of type "α list → α"."hd l" returns the first element of l. It raises
Emptyif l is nil. -
LIST_TL
Function "List.tl", of type "α list → α list"."tl l" returns all but the first element of l. It raises
emptyif l is nil. -
LIST_LAST
Function "List.last", of type "α list → α"."last l" returns the last element of l. It raises
emptyif l is nil. -
LIST_GET_ITEM
Function "List.getItem", of type "α list → (α * α list) option"."getItem l" returns
NONEif the list is empty, andSOME(hd l,tl l)otherwise. This function is particularly useful for creating value readers from lists of characters. For example,Int.scan StringCvt.DEC getItemhas the type(int, char list) StringCvt.readerand can be used to scan decimal integers from lists of characters. -
LIST_NTH
Function "List.nth", of type "α list * int → α"."nth (l, i)" returns the
ith element of the listl, counting from 0. It raisesSubscriptifi < 0ori >= length l. We haventh(l,0) = hd l, ignoring exceptions. -
LIST_TAKE
Function "List.take", of type "α list * int → α list"."take (l, i)" returns the first i elements of the list l. It raises
Subscriptif i < 0 or i > length l. We havetake(l, length l) = l. -
LIST_DROP
Function "List.drop", of type "α list * int → α list"."drop (l, i)" returns what is left after dropping the first i elements of the list l.
It raises
Subscriptif i < 0 or i > length l.It holds that
take(l, i) @ drop(l, i) = lwhen 0 ≤ i ≤ length l.We also have
drop(l, length l) = []. -
LIST_REV
Function "List.rev", of type "α list → α list"."rev l" returns a list consisting of l's elements in reverse order.
-
LIST_CONCAT
Function "List.concat", of type "α list list → α list"."concat l" returns the list that is the concatenation of all the lists in l in order.
concat[l1,l2,...ln] = l1 @ l2 @ ... @ ln -
LIST_REV_APPEND
Function "List.revAppend", of type "α list * α list → α list"."revAppend (l1, l2)" returns (rev l1) @ l2.
-
LIST_APP
Function "List.app", of type "(α → unit) → α list → unit"."app f l" applies f to the elements of l, from left to right.
-
LIST_MAP
Function "List.map", of type "(α → β) → α list → β list"."map f l" applies f to each element of l from left to right, returning the list of results.
-
LIST_MAP_PARTIAL
Function "List.mapPartial", of type "(α → β option) → α list → β list"."mapPartial f l" applies f to each element of l from left to right, returning a list of results, with SOME stripped, where f was defined. f is not defined for an element of l if f applied to the element returns NONE. The above expression is equivalent to:
((map valOf) o (filter isSome) o (map f)) l -
LIST_FIND
Function "List.find", of type "(α → bool) → α list → α option"."find f l" applies f to each element x of the list l, from left to right, until
f xevaluates to true. It returns SOME(x) if such an x exists; otherwise it returns NONE. -
LIST_FILTER
Function "List.filter", of type "(α → bool) → α list → α list"."filter f l" applies f to each element x of l, from left to right, and returns the list of those x for which
f xevaluated to true, in the same order as they occurred in the argument list. -
LIST_PARTITION
Function "List.partition", of type "(α → bool) → α list → α list * α list"."partition f l" applies f to each element x of l, from left to right, and returns a pair (pos, neg) where pos is the list of those x for which
f xevaluated to true, and neg is the list of those for whichf xevaluated to false. The elements of pos and neg retain the same relative order they possessed in l. -
LIST_FOLDL
Function "List.foldl", of type "(α * β → β) → β → α list → β"."foldl f init [x1, x2, ..., xn]" returns
f(xn,...,f(x2, f(x1, init))...)orinitif the list is empty. -
LIST_FOLDR
Function "List.foldr", of type "(α * β → β) → β → α list → β"."foldr f init [x1, x2, ..., xn]" returns
f(x1, f(x2, ..., f(xn, init)...))orinitif the list is empty. -
LIST_EXISTS
Function "List.exists", of type "(α → bool) → α list → bool"."exists f l" applies f to each element x of the list l, from left to right, until
f xevaluates to true; it returns true if such an x exists and false otherwise. -
LIST_ALL
Function "List.all", of type "(α → bool) → α list → bool"."all f l" applies f to each element x of the list l, from left to right, until
f xevaluates to false; it returns false if such an x exists and true otherwise. It is equivalent to not(exists (not o f) l)). -
LIST_TABULATE
Function "List.tabulate", of type "int * (int → α) → α list"."tabulate (n, f)" returns a list of length n equal to
[f(0), f(1), ..., f(n-1)], created from left to right. It raisesSizeif n < 0. -
LIST_COLLATE
Function "List.collate", of type "(α * α → order) → α list * α list → order"."collate f (l1, l2)" performs lexicographic comparison of the two lists using the given ordering f on the list elements.
-
MATH_ACOS
Function "Math.acos", of type "real → real"."acos x" returns the arc cosine of x. acos is the inverse of cos. Its result is guaranteed to be in the closed interval [0,pi]. If the magnitude of x exceeds 1.0, returns NaN.
-
MATH_ASIN
Function "Math.asin", of type "real → real"."asin x" returns the arc sine of x. asin is the inverse of sin. Its result is guaranteed to be in the closed interval [-pi / 2, pi / 2]. If the magnitude of x exceeds 1.0, returns NaN.
-
MATH_ATAN
Function "Math.atan", of type "real → real"."atan x" returns the arc tangent of x. atan is the inverse of tan. For finite arguments, the result is guaranteed to be in the open interval (-pi / 2, pi / 2). If x is +infinity, it returns pi / 2; if x is -infinity, it returns -pi / 2.
-
MATH_ATAN2
Function "Math.atan2", of type "real *real → real"."atan2 (x, y)" returns the arc tangent of (y / x) in the closed interval [-pi, pi], corresponding to angles within +-180 degrees. The quadrant of the resulting angle is determined using the signs of both x and y, and is the same as the quadrant of the point (x, y). When x = 0, this corresponds to an angle of 90 degrees, and the result is (real (sign y)) * pi / 2.0. It holds that
sign (cos (atan2 (y, x))) = sign (x)
and
sign (sin (atan2 (y, x))) = sign (y)
except for inaccuracies incurred by the finite precision of real and the approximation algorithms used to compute the mathematical functions. Rules for exceptional cases are specified in the following table.
y x atan2(y, x) ================= ========= ========== +-0 0 < x +-0 +-0 +0 +-0 +-0 x < 0 +-pi +-0 -0 +-pi y, 0 < y +-0 pi/2 y, y < 0 +-0 -pi/2 +-y, finite y > 0 +infinity +-0 +-y, finite y > 0 -infinity +-pi +-infinity finite x +-pi/2 +-infinity +infinity +-pi/4 +-infinity -infinity +-3pi/4 -
MATH_COS
Function "Math.cos", of type "real → real"."cos x" returns the cosine of x, measured in radians. If x is an infinity, returns NaN.
-
MATH_COSH
Function "Math.cosh", of type "real → real"."cosh x" returns the hyperbolic cosine of x, that is, (e(x) + e(-x)) / 2. It has the properties cosh +-0 = 1, cosh +-infinity = +-infinity.
-
MATH_E
Constant "Math.e", of type "real", is the base e (2.718281828...) of the natural logarithm. -
MATH_EXP
Function "Math.exp", of type "real → real"."exp x" returns e(x), i.e., e raised to the x(th) power. If x is +infinity, it returns +infinity; if x is -infinity, it returns 0.
-
MATH_LN
Function "Math.ln", of type "real → real"."ln x" returns the natural logarithm (base e) of x. If
x < 0, returns NaN; ifx = 0, returns -infinity; ifxis infinity, returns infinity. -
MATH_LOG10
Function "Math.log10", of type "real → real"."log10 x" returns the decimal logarithm (base 10) of x. If
x < 0, returns NaN; ifx = 0, returns -infinity; ifxis infinity, returns infinity. -
MATH_PI
Constant "Math.pi", of type "real" is the constant pi (3.141592653...). -
MATH_POW
Function "Math.pow", of type "real * real → real"."pow x" returns x(y), i.e., x raised to the y(th) power. For finite
xandy, this is well-defined whenx > 0, or whenx < 0andyis integral. Rules for exceptional cases are specified below.x y pow(x,y) ================= ============================= ========== x, including NaN 0 1 |x| > 1 +infinity +infinity |x| < 1 +infinity +0 |x| > 1 -infinity +0 |x| < 1 -infinity +infinity +infinity y > 0 +infinity +infinity y < 0 +0 -infinity y > 0, odd integer -infinity -infinity y > 0, not odd integer +infinity -infinity y < 0, odd integer -0 -infinity y < 0, not odd integer +0 x NaN NaN NaN y <> 0 NaN +-1 +-infinity NaN finite x < 0 finite non-integer y NaN +-0 y < 0, odd integer +-infinity +-0 finite y < 0, not odd integer +infinity +-0 y > 0, odd integer +-0 +-0 y > 0, not odd integer +0 -
MATH_SIN
Function "Math.sin", of type "real → real"."sin x" returns the sine of x, measured in radians. If x is an infinity, returns NaN.
-
MATH_SINH
Function "Math.sinh", of type "real → real"."sinh x" returns the hyperbolic sine of x, that is, (e(x) - e(-x)) / 2. It has the property sinh +-0 = +-0, sinh +-infinity = +-infinity.
-
MATH_SQRT
Function "Math.sqrt", of type "real → real"."sqrt x" returns the square root of
x. sqrt (~0.0) = ~0.0. Ifx < 0, it returns NaN. -
MATH_TAN
Function "Math.tan", of type "real → real"."tan x" returns the tangent of x, measured in radians. If x is an infinity, these returns NaN. Produces infinities at various finite values, roughly corresponding to the singularities of the tangent function.
-
MATH_TANH
Function "Math.tanh", of type "real → real"."tanh x" returns the hyperbolic tangent of x, that is, (sinh x) / (cosh x). It has the properties tanh +-0 = +-0, tanh +-infinity = +-1.
-
OPTION_GET_OPT
Function "Option.getOpt", of type "α option * α → α".getOpt(opt, a)returns v if opt is SOME(v); otherwise it returns a. -
OPTION_IS_SOME
Function "Option.isSome", of type "α option → bool".isSome optreturns true if opt is SOME(v); otherwise it returns false. -
OPTION_VAL_OF
Function "Option.valOf", of type "α option → α".valOf optreturns v if opt is SOME(v); otherwise it raisesOption. -
OPTION_FILTER
Function "Option.filter", of type "(α → bool) → α → α option".filter f areturns SOME(a) if f(a) is true and NONE otherwise. -
OPTION_JOIN
Function "Option.join", of type "α option option → α option".join optmaps NONE to NONE and SOME(v) to v.Because
joinis a keyword in Morel, you must quote the function name using backticks. For example:Option.`join` (SOME (SOME 1)); > val it = SOME 1 : int option -
OPTION_APP
Function "Option.app", of type "(α → unit) → α option → unit".app f optapplies the function f to the value v if opt is SOME(v), and otherwise does nothing. -
OPTION_MAP
Function "Option.map", of type "(α → β) → α option → β option".map f optmaps NONE to NONE and SOME(v) to SOME(f v). -
OPTION_MAP_PARTIAL
Function "Option.mapPartial", of type "(α → β option) → α option → β option".mapPartial f optmaps NONE to NONE and SOME(v) to f (v). -
OPTION_COMPOSE
Function "Option.compose", of type "(α → β) * (γ → α option) → γ → β option".compose (f, g) areturns NONE if g(a) is NONE; otherwise, if g(a) is SOME(v), it returns SOME(f v).Thus, the compose function composes
fwith the partial functiongto produce another partial function. The expression compose(f, g)is equivalent to(map f) o g. -
OPTION_COMPOSE_PARTIAL
Function "Option.composePartial", of type "(α → β option) * (γ → α option) → γ → β option".composePartial (f, g) areturns NONE if g(a) is NONE; otherwise, if g(a) is SOME(v), it returns f(v).Thus, the
composePartialfunction composes the two partial functionsfandgto produce another partial function. The expressioncomposePartial (f, g)is equivalent to(mapPartial f) o g. -
REAL_ABS
Function "Real.abs", of type "real → real".Returns the absolute value of
r. -
REAL_CEIL
Function "Real.ceil", of type "real → int".Returns largest int not larger than
r. -
REAL_CHECK_FLOAT
-
REAL_COMPARE
Function "Real.compare", of type "real * real → real".Returns
xwith the sign ofy, even if y is NaN. -
REAL_COPY_SIGN
Function "Real.copySign", of type "real * real → real".Returns
xwith the sign ofy, even if y is NaN. -
REAL_FLOOR
Function "Real.floor", of type "real → int".Returns smallest int not less than
r. -
REAL_FROM_INT
Function "Real.fromInt", of type "int → real". Converts the integerito arealvalue. If the absolute value ofiis larger thanmaxFinite, then the appropriate infinity is returned. Ificannot be exactly represented as arealvalue, then the current rounding mode is used to determine the resulting value. The top-level functionrealis an alias forReal.fromInt. -
REAL_FROM_MAN_EXP
Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns{man, exp}, wheremanandexpare the mantissa and exponent of r, respectively. -
REAL_FROM_STRING
Function "Real.fromString s", of type "string → real option", scans arealvalue from astring. ReturnsSOME(r)if arealvalue can be scanned from a prefix ofs, ignoring any initial whitespace; otherwise, it returnsNONE. This function is equivalent toStringCvt.scanString scan. -
REAL_IS_FINITE
Function "Real.isFinite", of type "real → bool"."isFinite x" returns true if
xis neither NaN nor an infinity. -
REAL_IS_NAN
Function "Real.isNan", of type "real → bool"."isNan x" returns true if
xis NaN. -
REAL_IS_NORMAL
Function "Real.isNormal", of type "real → bool"."isNormal x" returns true if
xis normal, i.e., neither zero, subnormal, infinite nor NaN. -
REAL_NEG_INF
Constant "Real.negInf", of type "real".The negative infinity value.
-
REAL_POS_INF
Constant "Real.posInf", of type "real".The positive infinity value.
-
REAL_RADIX
Constant "Real.radix", of type "int".The base of the representation, e.g., 2 or 10 for IEEE floating point.
-
REAL_PRECISION
Constant "Real.precision", of type "int".The number of digits, each between 0 and
radix - 1, in the mantissa. Note that the precision includes the implicit (or hidden) bit used in the IEEE representation (e.g., the value of Real64.precision is 53). -
REAL_MAX
Function "Real.max", of type "real * real → real".Returns the returns the larger of the arguments. If exactly one argument is NaN, returns the other argument. If both arguments are NaN, returns NaN.
-
REAL_MAX_FINITE
Constant "Real.maxFinite", of type "real".The maximum finite number.
-
REAL_MIN
Function "Real.min", of type "real * real → real".Returns the returns the larger of the arguments. If exactly one argument is NaN, returns the other argument. If both arguments are NaN, returns NaN.
-
REAL_MIN_POS
Constant "Real.minPos", of type "real".The minimum non-zero positive number.
-
REAL_MIN_NORMAL_POS
Constant "Real.minNormalPos", of type "real".The minimum non-zero normalized number.
-
REAL_REAL_MOD
Function "Real.realMod", of type "real * real → real".Returns the fractional part of r. "realMod" is equivalent to "#frac o split".
-
REAL_REAL_CEIL
Function "Real.realCeil", of type "real → real".Returns the smallest integer-valued real not less than
r. -
REAL_REAL_FLOOR
Function "Real.realFloor", of type "real → real".Returns the largest integer-valued real not larger than
r. -
REAL_REAL_ROUND
Function "Real.realRound", of type "real → real".Returns the integer-valued real nearest to
r. In the case of a tie, it rounds to the nearest even integer. -
REAL_REAL_TRUNC
Function "Real.realTrunc", of type "real → real".Returns the
rrounded towards zero. -
REAL_REM
Function "Real.rem", of type "real * real → real".Returns the remainder
x - n * y, wheren = trunc (x / y). The result has the same sign asxand has absolute value less than the absolute value ofy. Ifxis an infinity oryis 0, returns NaN. Ifyis an infinity, returnsx. -
REAL_ROUND
Function "Real.round", of type "real → int".Returns the integer nearest to
r. In the case of a tie, it rounds to the nearest even integer. -
REAL_SAME_SIGN
Function "Real.sameSign", of type "real * real → bool".Returns true if and only if
signBit r1equalssignBit r2. -
REAL_SIGN
Function "Real.sign", of type "real → int".Returns ~1 if r is negative, 0 if r is zero, or 1 if r is positive. An infinity returns its sign; a zero returns 0 regardless of its sign. It raises
Domainon NaN. -
REAL_SIGN_BIT
Function "Real.signBit", of type "real → bool".Returns true if and only if the sign of
r(infinities, zeros, and NaN, included) is negative. -
REAL_SPLIT
Function "Real.split", of type "real → {frac:real, whole:real}".Returns
{frac, whole}, wherefracandwholeare the fractional and integral parts ofr, respectively. Specifically,wholeis integral,|frac| < 1.0,wholeandfrachave the same sign asr, andr = whole + frac.This function is comparable to
modfin the C library. Ifris +-infinity,wholeis +-infinity andfracis +-0. Ifris NaN, bothwholeandfracare NaN. -
REAL_TO_MAN_EXP
Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns{man, exp}, wheremanandexpare the mantissa and exponent of r, respectively. -
REAL_TO_STRING
Function "Real.toString", of type "real → string"."toString r" converts reals into strings. The value returned by
toString tis equivalent to:(fmt (StringCvt.GEN NONE) r) -
REAL_TRUNC
Function "Real.trunc", of type "real → int".Returns
rrounded towards zero. -
REAL_UNORDERED
Function "Real.unordered", of type "real * real → bool"."unordered (x, y) returns true if
xandyare unordered, i.e., at least one ofxandyis NaN. -
RELATIONAL_COUNT
Function "Relational.count", aka "count", of type "int list → int".Often used with
group:from e in emps group deptno = (#deptno e) compute sumId = sum of (#id e) -
RELATIONAL_EXISTS
Function "Relational.exists", aka "exists", of type "α list → bool".For example,
from d in depts where exists ( from e in emps where e.deptno = d.deptno andalso e.job = 'CLERK') -
RELATIONAL_NOT_EXISTS
Function "Relational.notExists", aka "notExists", of type "α list → bool".For example,
from d in depts where notExists ( from e in emps where e.deptno = d.deptno andalso e.job = 'CLERK')notExists listis equivalent tonot (exists list), but the former may be more convenient, because it requires fewer parentheses. -
RELATIONAL_ONLY
Function "Relational.only", aka "only", of type "α list → α"."only list" returns the only element of
list. It raisesEmptyiflistis nil,Sizeiflisthas more than one element."only" allows you to write the equivalent of a scalar sub-query:
from e in emps yield {e.ename, dname = only (from d in depts where d.deptno = e.deptno yield d.dname)} -
RELATIONAL_ITERATE
Function "Relational.iterate", aka "iterate", of type "α list → (α list → α list → α list) → α list"."iterate initialList listUpdate" computes a fixed point, starting with a list and iterating by passing it to a function.
-
RELATIONAL_SUM
Function "Relational.sum", aka "sum", of type "α list → α" (where α must be numeric).Often used with
group:from e in emps group deptno = (#deptno e) compute sumId = sum of (#id e) -
RELATIONAL_MAX
Function "Relational.max", aka "max", of type "α list → α" (where α must be comparable). -
RELATIONAL_MIN
Function "Relational.min", aka "min", of type "α list → α" (where α must be comparable). -
SYS_ENV
Function "Sys.env", aka "env", of type "unit → string list". -
SYS_FILE
Value "Sys.file", aka "file", of type "{...}" (partial record).Its value is not global; each session has a private value. This allows the type to be different for each session, and reduces concern thread-safety concerns.
-
SYS_PLAN
Function "Sys.plan", aka "plan", of type "unit → string". -
SYS_SET
Function "Sys.set", aka "set", of type "string * α → unit". -
SYS_SHOW
Function "Sys.show", aka "set", of type "string → string option". -
SYS_UNSET
Function "Sys.unset", aka "unset", of type "string → unit". -
VECTOR_MAX_LEN
Constant "Vector.maxLen" of type "int".The maximum length of vectors supported by this implementation. Attempts to create larger vectors will result in the
Sizeexception being raised. -
VECTOR_FROM_LIST
Function "Vector.fromList" of type "α list → α vector".fromList lcreates a new vector froml, whose length islength land with theith element oflused as theith element of the vector. If the length of the list is greater thanmaxLen, then theSizeexception is raised. -
VECTOR_TABULATE
Function "Vector.tabulate" of type "int * (int → α) → α vector".tabulate (n, f)creates a vector ofnelements, where the elements are defined in order of increasing index by applyingfto the element's index. This is equivalent to the expression:fromList (List.tabulate (n, f))If
n < 0ormaxLen < n, then theSizeexception is raised. -
VECTOR_LENGTH
Function "Vector.length" of type "α vector → int".length vecreturns|vec|, the length of the vectorvec. -
VECTOR_SUB
Function "Vector.sub" of type "α vector * int → α".sub (vec, i)returns theith element of the vectorvec. Ifi < 0or|vec| <= i, then theSubscriptexception is raised. -
VECTOR_UPDATE
Function "Vector.update" of type "α vector * int * α → α vector".update (vec, i, x)returns a new vector, identical tovec, except theith element ofvecis set tox. Ifi < 0or|vec| <= i, then theSubscriptexception is raised. -
VECTOR_CONCAT
Function "Vector.concat" of type "α vector list → α vector".concat lreturns the vector that is the concatenation of the vectors in the listl. If the total length of these vectors exceedsmaxLen, then theSizeexception is raised. -
VECTOR_APPI
Function "Vector.appi" of type "(int * α → unit) → α vector → unit".appi f vecapplies the functionfto the elements of a vector in left to right order (i.e., in order of increasing indices). Theappifunction is more general thanapp, and supplies both the element and the element's index to the functionf. Equivalent to:List.app f (foldri (fn (i,a,l) => (i,a)::l) [] vec) -
VECTOR_APP
Function "Vector.app" of type "(α → unit) → α vector → unit".app f vecapplies the functionfto the elements of a vector in left to right order (i.e., in order of increasing indices). Equivalent to:List.app f (foldr (fn (a,l) => a::l) [] vec) -
VECTOR_MAPI
Function "Vector.mapi" of type "(int * α → β) → α vector → β vector".mapi f vecproduces a new vector by mapping the functionffrom left to right over the argument vector. The formmapiis more general, and suppliesfwith the vector index of an element along with the element. Equivalent to:fromList (List.map f (foldri (fn (i,a,l) => (i,a)::l) [] vec)) -
VECTOR_MAP
Function "Vector.map" of type "(α → β) → α vector → β vector".map f vecproduces a new vector by mapping the functionffrom left to right over the argument vector. Equivalent to:fromList (List.map f (foldr (fn (a,l) => a::l) [] vec)) -
VECTOR_FOLDLI
Function "Vector.foldli" of type "(int * α * β → β) → β → α vector → β".foldli f init vecfolds the functionfover all the elements of a vector, using the valueinitas the initial value. Applies the functionffrom left to right (increasing indices). The functionsfoldliandfoldriare more general, and supply both the element and the element's index to the function f. -
VECTOR_FOLDRI
Function "Vector.foldri" of type "(int * α * β → β) → β → α vector → β".foldri f init vecfolds the functionfover all the elements of a vector, using the valueinitas the initial value. Applies the functionffrom right to left (decreasing indices). The functionsfoldliandfoldriare more general, and supply both the element and the element's index to the function f. -
VECTOR_FOLDL
Function "Vector.foldl" of type "(α * β → β) → β → α vector → β".foldl f init vecfolds the functionfover all the elements of a vector, using the valueinitas the initial value. Applies the functionffrom left to right (increasing indices). Equivalent tofoldli (fn (_, a, x) => f(a, x)) init vec -
VECTOR_FOLDR
Function "Vector.foldr" of type "(α * β → β) → β → α vector → β".foldr f init vecfolds the functionfover all the elements of a vector, using the valueinitas the initial value. Applies the functionffrom right to left (decreasing indices). Equivalent tofoldri (fn (_, a, x) => f(a, x)) init vec -
VECTOR_FINDI
Function "Vector.findi" of type "(int * α → bool) → α vector → (int * α) option".findi f vecappliesfto each element of the vectorvec, from left to right (i.e., increasing indices), until atruevalue is returned. If this occurs, the function returns the element; otherwise, it returnNONE. The functionfindiis more general thanfind, and also suppliesfwith the vector index of the element and, upon finding an entry satisfying the predicate, returns that index with the element. -
VECTOR_FIND
Function "Vector.find" of type "(α → bool) → α vector → α option".find f vecappliesfto each element of the vectorvec, from left to right (i.e., increasing indices), until atruevalue is returned. If this occurs, the function returns the element; otherwise, it returnsNONE. -
VECTOR_EXISTS
Function "Vector.exists" of type "(α → bool) → α vector → bool".exists f vecappliesfto each elementxof the vectorvec, from left to right (i.e., increasing indices), untilf(x)evaluates totrue; it returnstrueif such anxexists andfalseotherwise. -
VECTOR_ALL
Function "Vector.all" of type "(α → bool) → α vector → bool".all f vecappliesfto each elementxof the vectorvec, from left to right (i.e., increasing indices), untilf(x)evaluates tofalse; it returnsfalseif such anxexists andtrueotherwise. It is equivalent tonot (exists (not o f) vec)). -
VECTOR_COLLATE
Function "Vector.collate" of type "(α * α → order) → α vector * α vector → order".collate f (v1, v2)performs lexicographic comparison of the two vectors using the given orderingfon elements. -
Z_ANDALSO
Internal operator "andalso", of type "bool * bool → bool". -
Z_ORELSE
Internal operator "orelse", of type "bool * bool → bool". -
Z_NEGATE_INT
Internal unary negation operator "~", of type "int → int". -
Z_NEGATE_REAL
Internal unary negation operator "~", of type "real → real". -
Z_DIVIDE_INT
Internal divide operator "/", of type "int * int → int". -
Z_DIVIDE_REAL
Internal divide operator "/", of type "real * real → real". -
Z_MINUS_INT
Internal minus operator "-", of type "int * int → int". -
Z_MINUS_REAL
Internal minus operator "-", of type "real * real → real". -
Z_PLUS_INT
Internal plus operator "+", of type "int * int → int". -
Z_PLUS_REAL
Internal plus operator "+", of type "real * real → real". -
Z_TIMES_INT
Internal times operator "*", of type "int * int → int". -
Z_TIMES_REAL
Internal times operator "*", of type "real * real → real". -
Z_SUM_INT
Internal relational sum operator "sum", of type "int * int → int". -
Z_SUM_REAL
Internal relational sum operator "sum", of type "real * real → real". -
Z_EXTENT
Internal type extent, e.g. "extent: bool list" returns "[false, true]", "extent: (int * bool) list" returns "[(0, false), (0, true), (1, false), (1, true), ...]".These returns are hypothetical; except for
booland some algebraic types, the extent is practically infinite. It will need to be removed during planning.Its type is "unit → * α list". It would not be possible to derive the type if "extent" were used in code.
-
Z_LIST
Internal list constructor, e.g. "list (1 + 2, 3)" implements "[1 + 2, 3]". It cannot be assigned a type, because the tuple is variadic.
-
-
Field Details
-
structure
Name of the structure (e.g. "List", "String"), or null. -
mlName
Unqualified name, e.g. "map" (for "List.map") or "true". -
alias
An alias, or null. For example, "List.map" has an alias "map". -
typeFunction
Derives a type, in a particular type system, for this constant or function. -
preferredType
-
sessionValue
Computes a value for a particular session. -
BY_ML_NAME
-
BY_STRUCTURE
-
-
Constructor Details
-
BuiltIn
-
BuiltIn
private BuiltIn(@Nullable String structure, String mlName, @Nonnull PrimitiveType preferredType, Function<TypeSystem, Type> typeFunction) -
BuiltIn
-
BuiltIn
private BuiltIn(@Nullable String structure, String mlName, @Nullable String alias, Function<TypeSystem, Type> typeFunction, @Nullable PrimitiveType preferredType, @Nullable Function<Session, Object> sessionValue)
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
forEach
Calls a consumer once per value. -
forEachStructure
public static void forEachStructure(TypeSystem typeSystem, BiConsumer<BuiltIn.Structure, Type> consumer) Calls a consumer once per structure. -
dataTypes
Defines built-indatatypeandeqtypeinstances, e.g.option,vector. -
defineEqType
-
defineDataType
private static void defineDataType(TypeSystem ts, List<Binding> bindings, String name, boolean internal, int varCount, UnaryOperator<BuiltIn.DataTypeHelper> transform) -
reverse
Returns the reverse comparison operator, R, such that "x this y" if and only if "y R x". -
prefer
-