This chapter is a reference guide to the Estimator statements. These statements contain the basic control flow operators for the Estimator language. All of the basic building blocks of Estimator are contained in its statements. Estimator is case sensitive.
All Estimator statements are lexical structures, which are understood only by the Estimator parser. They are not understood by the system outside of the Estimator parser, and they are not available nor are they understood by Lisp. All Estimator statements have meaning only at parse time.
All Estimator special forms are structures, which are understood only by the Estimator compiler. Unlike Function objects, the Estimator special forms are invalid outside of compilation, at run time.
Estimator supports user defined global symbols, allowing the user to assign any valid Estimator object to the newly created global symbol. User defined global symbols behave just like their built-in cousins; however, Estimator even allows the user to redefine any of the built-in Estimator special form symbols.
Estimator supports the basic binary and unary arithmetic operations: addition (+), subtraction (-), multiplication (*), division (/), protected division (#), and modulus (%).
Statement
operand1 binaryOperator operand2
Arguments | Explanation |
---|---|
Operand1 | The first operand. |
binaryOperator | The binary operator. Must be one of: +, -, *, /, #, %. |
Operand2 | The second operand. |
RETURN | The result of the binary operation. |
Use the binary operator statement to perform basic arithmetic operations on two numeric values, or to concatenate two string values.
These simple examples demonstrates the effect of the various binary operators.
a = 1 + 20;
//Returns
21
b = 30 - 5;
//Returns 25
c = 2 * 2.1;
//Returns 4.2
d = 100 / 10;
//Returns 10
e = 10 % 4;
//Returns 2 (the remainder)
The binary operator statement performs basic arithmetic operations on two numeric values, or concatenates two string values.
On a divsion by zero, the protected divide operator returns the highest possible number in the system if the sign of the numerator is negative or the lowest possible number in the system if the sign of the numerator is positive.
Estimator supports the basic unary arithmetic operations: increment (++), decrement (--), and negation (-).
Syntax: unaryOperator operand1
Statement
unaryOperator operand1
operand1 incrementOperator
operand1 decrementOperator
Arguments | Explanation |
---|---|
unaryOperator | The unary operator. Must be one of: ++, --, -. |
Operand | The first operand. |
RETURN | The result of the unary operation. |
Use the unary operator statement to perform basic arithmetic operations on a single numeric value.
These simple examples demonstrates the effect of the various unary operators.
var a = 100;
var b = 100;
var c = 10;
var d = 10;
++a; //Returns 101
--b; //Returns 99
c++; //Returns 11
d--; //Returns 9
-a; //Returns -101
The unary operator statement performs basic arithmetic operations on a single numeric value.
Estimator assigns a value to a variable with the = (equal) operator. Another class of assignment operators perform math operations on the variable and saves the result in the same variable. They are +=, -=, *=, /=and %=. The += operator is shorthand for a=a + exp.
Statement
variable assignmentOperator expression
Arguments | Explanation |
---|---|
variable | The variable to be assigned a new value. |
assignmentOperator | The assignment Operator. Must be one of: =, +=, -=, *=, /=, %=. |
expression | If the assignmentOperator is (=), the expression may return any value. If the assignmentOperator is (+=, -=, *=, /=, or %=), then the expression must return a numeric value. |
RETURN | If the assignmentOperator is (=), the variable is set to the value of expression. If the assignmentOperator is (+=, -=, *=, /=, or %=), then the arithmetic operation is performed on the original variable and the expression. |
Use the assignment operator statement to assign a new value to a Estimator variable.
This simple example demonstrates the effect of the simple assignment operator.
a = 3.14; //Returns 3.14
This examples demonstrate the effects of the arithmetic assignment operators.
var a = 100;
var b = 100;
var c = 10;
var d = 10;
a += 10; //Returns 110
b -= 10; //Returns 90
c *= 10; //Returns 100
The assignment operator statement assigns a new value to a Estimator variable.
The child function declaration creates a new Lambda object and assigns it to the specified persistent variable name childName of the parent Lambda parent. The child function declaration always returns the newly created object identifier of the new Lambda. The child Lambda is invoked using the parent.childName() syntax form.
Statement
child parent childName ([type] arg..) { cvardec pvardec vardec exp }
Arguments | Explanation |
---|---|
child |
Mandatory keyword. |
parent |
Name of the parent class |
childName |
The name of the child Lambda (function) |
([type] arg...) |
A list of type hints (optional) and arguments separated by commas. If there are no arguments the parenthesis are still required. Note: The optional type hints can be one of the following: char, bool, int, float, or obj |
cvardec |
Optional declaration. If present, must be followed by a persistent class variable declaration. See cvar. |
pvardec |
Optional declaration. If present, must be followed by a persistent variable declaration. See pvar. |
vardec |
Optional declaration. If present, must be followed by a local variable declaration. See var. |
exp |
The Estimator statements that form the Lambda |
RETURN | An Lambda object. |
Use the child statement to create a new Estimator Lambda with a child relationship to a parent Lambda.
This simple example demonstrates the effect of the simple assignment operator.
function foo(x) { pvar y; y = x return (y); } child foo sum (x) { var temp ; temp = x + y; return ( temp ); }
We can invoke the parent and the child Lambda as follows:
foo(10); //Returns 10 foo.sum(3); //Returns 13 compareEQ(foo.Cv, foo.sum.Cv); //Returns true compareEQ(foo.Pv, foo.sum.Pv); //Returns true
The child statement creates a new Estimator Lambda with a child relationship to a parent Lambda. A Child Lambda inherits pvar and cvar structures from its parent Lambda.
The class statement declares a class and names all of its members. The class statement can also use to sub-class, i.e., create a class that inherits from another class and extend it.
Statement
class className {member1 ; member2 ... }
class className extends parentClass {member1 ; member2 ... }
Arguments | Explanation |
---|---|
class |
Mandatory Keyword |
className |
The name of this class |
extends |
Optional Keyword. If present, it must be followed by an existing parent class. |
{member1; member2; ...} |
The names of the class members, where each name is separated by a semicolon |
RETURN | An class name. |
Use the class statement to create a new class or to extend and existing class through in heritance.
This simple example demonstrates the effect of the simple assignment operator.
class employee {Name; Address; Salary } emp = new ('employee' , 'Name' ,"Tom Jones" , 'Address', "200 Main Street, Small Town, USA" ) display(emp.Name)
This simple example demonstrates the effect of the simple assignment operator.
class employee {Name; Address; Salary } class manager extends 'employee' {Perks } emp = new ('employee' , 'Name' ,"Tom Jones" , 'Address', "200 Main Street, Small Town, USA" ) mgr = new('manager', 'Name', "John Smith", 'Perks', "Special Parking Space")
The class statement creates a new class or to extend and existing class through in heritance.
The comparison operators are ==(equal) , !=(not equal) ,< (less than) , <=(less than or equal) , > (greater than), >=(greater than or equal) . The resulting value is a Boolean value of true if the relational operator results in a true comparison otherwise the resulting value is false. Estimator performs type checking and type conversions, therefore the operands need not be the same type.
(obj1 operator obj2)
obj1 | First object to be compared |
operator | Must be ==(equal), !=(not equal) ,< (less than) , <=(less than or equal) , > (greater than), >=(greater than or equal). |
obj2 | Second object to be compared |
Returns | Returns true if the comparison is true, false if the comparison is false |
Example1
var a = true; //Returns True (a == true ); //Returns True ( 2 < 3); //Returns True ( 2 > 3); //Returns False
A conditional expression is a shorthand version of the if-else statement. Besides having a shorter syntax, conditional expression always return a value, unlike the if statement.
condition ? val1 : val2
condition | A Boolean expression |
? |
Mandatory operator |
val1 |
The value to be returned if condition is true. |
: |
Mandatory operator |
val2 |
The value to be returned if condition is false. |
Returns |
If the condition is true, val1 is returned, otherwise val2 is returned |
Example1
a = 1; X = (a >= 1) ? 1 : -1 ); // X will be set to 1
The cvar statement declares a persistent class variable within an Lambda. This means that the persistent class variable will have a scope for the life of the Lambda object. The class variable is created and initialized when the Lambda is instantiated and re-initialized each time the Lambda is invoked. Although Estimator is a dynamically typed language, the cvar allows the programmer to optionally provide hints to the compiler by specifying a type for variable declarations. The supported types are: char, bool, int, float, and obj. Specifying a type of obj is equivalent to specifying no type information.
cvar varName
cvar varName=init
cvar type varName
cvar type varName=init
cvar |
Mandatory keyword |
type | obj char bool int float obj text string symbol bitvec fltvec pcdvec stc dir dic matrix nummat vec bitvec numvec intvec objvec |
cvarName |
The name of the persistent class variable |
=init |
Optional argument. If present, the compiler will assign the cvarName to the value in init. |
When To Use
Unlike a temporary variable (var) that is declared inside a function and which is only "alive" while the function is currently active, a cvar (persistent variable) is accessible, as long the Lambda object instance is active. The contents of the entire cvar structure is in LambdaName.Cv, where LambdaName is the name of the instance of the Lambda. The contents of a single cvar variable is LambdaName.Cv.memberName;
A persistent class variable (cvar) is analogous to a static variable in a C or C++ programming environment. It is created and initialized when the Lambda is instantiated and it is persistent, meaning the memory is not released as long as the Lambda is in memory. However, the cvar differs from the pvar in that it is always re-initialized on entry to the Lambda that encapsulates it.
Example1
function squareIt(x) { cvar float xx; var y; xx = x * x; y = xx; return (xx); } var result, int; result = squareIt(10); writeln(result); //displays "100" writeln(squareIt.Cv.xx); //displays "100" writeln(squareIt.y); //error !Cannot find name: y in the PV structure of Lambda squareIt!
Example2
function foo (x) { cvar z; z = x; return(z); } var z; result = foo(7); display(result); //displays "7" display(z); //displays #void (accesses the contents of the global variable) display(foo.Cv.z); //displays "7"
Notes and Hints
The scope of variables in nested Lambdas depends upon the following compilation rules: Nested Lambdas do not share either their arguments or their temporary variables. The argument and the temporary variables are always limited in scope to the immediate Lambda object. A nested Lambda shares the persistent variables (pvar) and the persistent class variables (cvar) of its parents. When a variable reference is encountered, the Estimator compiler first searches the local Lambda's temporary variables (var), then the persistent variable structure (pvar), then the persistent class structure (cvar), and finally the global variables.
Also note: Any variable that is used without explicit declaration is automatically declared as a global variable. (This is true even if it is used inside a function definition).
The for statement repeats a set of Estimator statements until the specified condition is false.
for ( initexp; cond; increxp ) { exp ... }
for |
Mandatory keyword |
Initexp; |
Initializer expression. Usually resets an index to be used to determine loop control |
cond; |
An expression that returns a Boolean value. Usually tests the loop index to see if has reached a max number. |
Increxp |
Increment expression. Usually increments (or decrements) the loop index. |
{expr...} |
A set of Estimator statements |
Example1
var int a; for (a = 1; a < 10; ++a ) { display(" ", a)}
This will display the following line in the console screen:
1 2 3 4 5 6 7 8 9
The friend statement creates a new Lambda object and assigns it to the specified persistent variable name friendName of the parent Lambda parent. The friend function declaration always returns the newly created Lambda object. The new friend Lambda is invoked by using the parent.friendName ()
friend parent friendName ([type] arg..) { cvardec pvardec vardec exp}
friend |
Mandatory keyword. |
parent |
Name of the parent class |
friendName |
The name of the friend Lambda (function) |
([type] arg...) |
A list of type hints (optional) and arguments separated by commas. If there are no arguments the parenthesis are still required. Note: The optional type hints can be one of the following: char, bool, int, float, or obj |
cvardec |
Optional declaration. If present, must be followed by a persistent class variable declaration. See cvar. |
pvardec |
Optional declaration. If present, must be followed by a persistent variable declaration. See pvar. |
vardec |
Optional declaration. If present, must be followed by a local variable declaration. See var. |
exp |
The Estimator statements that form the Lambda |
Returns |
Lambda object identifier |
Example1
function foo(x) {We can invoke the parent and friend Lambdas as follows:
foo(10); //Returns 10 foo.sum(3); //Returns 28 compareEQ(foo.Pv, foo.sum.Cv); //Returns true compareEQ(foo.Pv, foo.sum.Pv); //Returns false
Notes and Hints
A friend Lambda has a different pvar structure than its parent Lambda, but the cvar structure of a friend Lambda is the pvar structure of its parent Lambda.
The frmregress command trains a multivariate factor regression on the specified numeric expression list. The frmregress statement should be the ONLY statement in the Estimator program, and returns the trained multivariate factor regression Lambda.
frmregress(numericExpression1,numericExpression2,,...,numericExpressionN);
frmregress | Mandatory keyword |
numericExpression1 | Numeric expression. |
numericExpressionN | Numeric expression. |
frmregress(exp(x4),x10);
This will train a multivariate factor regression model on the numeric expressions: exp(x4) and x10.
Note: Inside the numericExpressions, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
A Estimator function compiles into a first class Lambda object. It has the same footprint and is treated like any Lambda Object created by any compiler in the LambdaClient development environment.
function name ([type] arg..) { cvardec pvardec vardec exp }
function ([type] arg..) { cvardec pvardec vardec exp }
function |
Mandatory keyword. |
name |
(Optional) The name of the Lambda (function) |
([type] arg...) |
A list of type hints (optional) and arguments separated by commas. If there are no arguments the parenthesis are still required. Note: The optional type hints can be one of the following: char, bool, int, float, or obj |
cvardec |
Optional Argument. If present, must be followed by a persistent variable declaration. See cvar. |
pvardec |
Optional Argument. If present, must be followed by a persistent variable declaration. See pvar. |
vardec |
Optional Argument. If present, must be followed by a local variable declaration. See var. |
exp |
The Estimator statements that form the Lambda |
Returns |
Lambda object identifier |
Note: A function with no name will generate an unnamed function.
When To Use
The function statement defines the name of an Lambda, its arguments, and the statements that comprise the Lambda.
Example1
function foo (x) { writeln( "The value of x is " , x); }
To invoke:
foo(29);
Example2
function sayHello ( ) { writeln( "Hello World"); }
To invoke:
sayHello();
Estimator functions may be called by name or by Object Identifier. The function to be invoked must always have a set of parenthesis following the function name. If the function requires arguments, the arguments are passed as a comma separated list inside the parenthesis.
name ()
name (arg ...)
Lambda.child ()
Lambda.friend ( arg ...)
class.method ()
class.method ( arg ...)
name |
The name of the function to be invoked. |
class.method |
Alternate form of function name. Must be a method of a specified class |
(arg...) |
A list of arguments separated by commas. If there are no arguments the parenthesis are still required. |
Returns |
Lambda object identifier |
Example1
foo (x) { display( "The value of x is " , x); }
To invoke:
foo (1998);
Example2
function foo(x) { pvar y; y = x; return (y); } child foo sum (x) { var temp; temp = x + y; return ( temp ); }
We can invoke the parent and the child Lambda as follows:
foo(10); //Returns 10 foo.sum(3); //Returns 13
The if statement selects one of two expressions to evaluate based upon the value of a {test} expression. If the {cond} evaluates to True, then the expressions in the {thenClause} is evaluated.
If the else keyword is present and the {test} evaluates to false, then the expressions in the {elseClause} is evaluated.
The {test} and {thenClause} expressions are mandatory. The {else} expression is optional. The braces {} are also mandatory.
The {elseClause} may also be an if statement therefore creating a limitless number of conditions and conditional paths.
if (test) { trueClause... }
if (test) { trueClause... } else { elseClause... }
if (test) { trueClause... } else if (test2) { exp ... }
test |
An expression that returns a Boolean value. Must be enclosed in parenthesis. |
thenClause |
The expression to be executed if the cond clause returned True |
else |
Optional Keyword |
elseClause |
Optional expression. If the else keyword is present the elseClause must be present. The expression to be executed if the cond clause returned False |
else if |
If present, must be a valid if statement. |
Returns |
Returns the value of the expression evaluated. If no else clause is specified, the returned value is the result of the condition expression. |
When To Use
The if statement is used whenever it is necessary to perform actions based on a condition
Example1
j=1if ( j < 10 ) { k = 100;} else { k = -100;} //sets k to 100
Example2
j = 2; if ( j < 10 ) { k = 100;} else if ( j == 0) {k = 10;} else if ( j == 1 ) {k = 100;} else if ( j == 2 ) {k = 1000;} //sets k to 1000
The logical operators are && (and) , || (or) , and ! (not) . The resulting value from a logical operation is a Boolean value. The && operator returns true if both operands are true, the || operator returns true if one or both operands are true, and the ! operator returns true if the operand is false, otherwise the ! operator returns false. Estimator performs type checking and type conversions, therefore if the operands are not Boolean, the operands are converted to Boolean.
(obj1 && obj2 )
(obj1 || obj2 )
obj1 |
First object to be compared |
operator |
Must be && (and) , || (or) |
obj2 |
Second object to be compared |
Returns |
The && operator returns true if both operands are true, otherwise it returns false. The || operator returns true if one or both operands are true otherwise it returns false. |
(!obj1)
! |
Logical not operator |
obj1 |
Object to be negated |
Returns |
Returns true if the operand is false, otherwise the ! operator returns false. |
Example1
var a = true, k; if ( 2 < 3) && (a == true) {k = 1;} else {k = 2;} // sets k to 1 if ( 2 > 3) || (a == true) {k = 1;} else {k = 2;} // sets k to 1 if ( 2 > 3) && (!a) {k = 1;} else {k = 2;}// sets k to 2
The method statement defines a method to Estimator class.
method className methodName([type] arg...) { expr }
method |
Mandatory keyword |
className |
Name of the parent class of the method |
methodName |
Name of this method. |
([type] arg...) |
A list of type hints (optional) and arguments separated by commas. If there are no arguments the parenthesis are still required. Note: The optional type hints can be one of the following: char, bool, int, float, or obj |
{expr} |
A set of Estimator statements |
Example1
class employee {Name; Address; Salary } method employee updateSalary( this, newSalary) { this.Salary = newSalary; } emp = new ('employee', 'Name', "Tom Jones", 'Address', "200 Main Street, Small Town, USA" ) emp.updateSalary(45000); writeln (emp.Name, "'s new salary is ", emp.Salary);Note: In a method declaration the receiving object (this) is declared, but is not passed in the function invocation.
emp.updateSalary(45000); // This is correct emp.updateSalary(emp,45000); // This is incorrect
The mvlregress command trains a multivariate linear regression on the specified numeric expression list. The mvlregress statement should be the ONLY statement in the Estimator program, and returns the trained multivariate linear regression Lambda.
mvlregress(numericExpression1,numericExpression2,,...,numericExpressionN);
mvlregress | Mandatory keyword |
numericExpression1 | Numeric expression. |
numericExpressionN | Numeric expression. |
mvlregress(exp(x4),x10);
This will train a multivariate linear regression model on the numeric expressions: exp(x4) and x10.
Note: Inside the numericExpressions, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The new function creates an instance of an object. The Lambda Information Server definition of an object is very specific. It is a memory resident container to store data, which is of variable length or is too large to fit in small fixed containers. The Analytic Information Server object Heap manager supports automated object resizing, garbage collection, and anti-fragmentation algorithms so that the user may concentrate on the analysis and modeling of data rather than on memory management.
The Estimator compiler supports all of the Analytic Information Server objects. Each object is covered in detail in its own chapter in the Lambda Information Server Programmer's Guide.
new ('objectType' )
new ('String' , value)
new ('Symbol' , value)
new ('Vector' , vecSubType, size)
new ('Vector', vecSubType, size, value)
new ('Structure', key, value)
new ('Structure', key, value ... . cdr )
new ('Dictionary', key, value)
new ('Directory', key, value)
new ('ObjectRepository', filename, 'key', code, 'buffer', count)
new |
Mandatory keyword |
objectType |
Must be 'String', 'Symbol', 'Vector', 'Structure' , 'Dictionary', 'Directory', 'ObjectRepository' |
value |
Optional Argument. If present, must be a constant of type objectType. |
vecSubType |
Optional argument, but if present must only be used with objectType, Vector. Valid vecSubtypes are 'normal' 'bit' 'integer' 'float' 'number' 'small' 'object' 'pcode'. If omitted, the default is normal vector. |
size |
Optional argument, but if present must only be used with objectType, Vector. It must be an integer representing the number of items the Vector will store. |
key, value |
Optional arguments to Structure, Dictionary, and Directory, but must appear in pairs. There may be an arbitrary number of key, value pairs. |
. cdr |
Optional Argument to Structure only. If present, it must be a constant that will be assigned to the cdr (tail) of a structure. |
filename |
If objectType is ObjectRepository, filename is a mandatory field which names the database archive file to be associated with the ObjectRepository. If no such file exists, a new database archive file will be created. |
'clear' |
If objectType is ObjectRepository, 'clear' is an optional keyword. If present, the database archive file will be cleared immediately before any further processing. If no such file exists, a new database archive file will be created. |
'key', code |
If objectType is ObjectRepository, 'key' is an optional keyword. If present and it must followed by a number. See ObjectRepository in the Programmer's Guide for more detail. |
'buffer',count |
If objectType is ObjectRepository, 'buffer' is an optional keyword. If the key word 'buffer' is present, the numeric buffered object count must follow. See ObjectRepository in the Programmer's Guide for more detail. |
Returns |
The new function will return an object identifier for the type specified in objectType . |
Example1
Estimator Syntax | Lisp Syntax |
new ('String', "John") | (new String: "John") |
new ('Symbol' , "Donald") | (new Symbol: "Donald") |
new ('Vector', 3, 11, 12, 99) | (new Vector: 3 11 12 99) |
new ('Vector' , 'bit', 5, 1 ) | (new Vector: bit: 5 1) |
new ('Structure', 'X', 22, 'Y', 34, ' .', 3) | (new Structure: X: 22 Y: 34 . 3) |
new ('Dictionary' , 'Name', "John Doe", 'Age', 30) | (new Dictionary: Name: "John Doe" Age: 30) |
new ('Directory' , 1, "New Year's Day", 2, "Valentine's Day" ) | (new Directory: 1 "New Year's Day" 2 "Valentine's Day" ) |
new ( 'ObjectRepository', "myarchive.odb") | (new ObjectRepository: "myarchive.odb") |
The orphan statement creates a new Lambda object and assigns it to the specified persistent variable name orphanName of the parent Lambda parent. The orphan function declaration always returns the newly created Lambda object. The new orphan Lambda is invoked by using the parent.orphanName () syntax form.
orphan parent orphanName ([type] arg..) { cvardec pvardec vardec exp}
orphan |
Mandatory keyword. |
parent |
Name of the parent class |
orphanName |
The name of the orphan Lambda (function) |
([type] arg...) |
A list of type hints (optional) and arguments separated by commas. If there are no arguments the parenthesis are still required. Note: The optional type hints can be one of the following: char, bool, int, float, or obj |
cvardec |
Optional declaration. If present, must be followed by a persistent class variable declaration. See cvar. |
pvardec |
Optional declaration. If present, must be followed by a persistent variable declaration. See pvar. |
vardec |
Optional declaration. If present, must be followed by a local variable declaration. See var. |
exp |
The Estimator statements that form the Lambda |
Returns |
Lambda object identifier |
Example1
function foo(x) { pvar y = 5; pvar d =30; var temp ; temp = x + d + y; return ( temp ); } orphan foo sum (x) { pvar d = 20 ; cvar e = 100 ; var temp ; temp = x + d + y; return ( temp ); }
We can invoke the parent and orphan Lambdas as follows:
y = 10; //declare a global variable foo(10); //Returns 45 foo.sum(10); //Returns 40 (uses the value of global y) compareEQ(foo.Cv, foo.sum.Cv); //Returns false compareEQ(foo.Pv, foo.sum.Pv); //Returns false
Notes and Hints
An orphan Lambda is a member of its parent's pvar structure. Therefore, the parent knows about the orphan. However, the orphan Lambda has a different pvar structure than its parent Lambda, and a different cvar structure than its parent Lambda. Therefore, an orphan Lambda knows nothing of its parent Lambda.
The pvar statement declares a persistent variable within an Lambda. This means that the persistent class variable will have a scope for the life of the Lambda object. The persistent variable is created and initialized when the Lambda is instantiated and not re-initialized each time the Lambda is invoked. Although Estimator is a dynamically typed language, the pvar allows the programmer to optionally provide hints to the compiler by specifying a type for variable declarations. The supported types are: char, bool, int, float, and obj. Specifying a type of obj is equivalent to specifying no type information.
Note: If type hints are supplied, the programmer must assure that no other types are saved in the variable.pvar varName
pvar varName = init
pvar type varName
pvar type varName = init
pvar |
Mandatory keyword |
type | obj char bool int float obj text string symbol bitvec fltvec pcdvec stc dir dic matrix nummat vec bitvec numvec intvec objvec |
pvarName |
The name of the persistent variable |
=init |
Optional argument. If present, the compiler will assign the pvarName to the value in init. |
When To Use
Unlike a var statement that is declared inside a function, the variables are only "alive" while the function is currently active. A pvar (persistent variable) is accessible, as long the Lambda object instance is active. The contents of the pvar structure is in LambdaName.Pv, where LambdaName is the name of the instance of the Lambda.
A persistent variable (pvar) is analogous to a static variable in a C or C++ programming environment. . It created and initialized when the Lambda is instantiated.
Unlike temporary variables (var), which are always allocated and initialized upon entry to a function and released upon exit, a pvar is initialized once and the memory allocated is fixed until the application ends.
Example1
function squareIt (x) { pvar xx; var y; xx = x * x; y = xx; return (xx); } var result; result = squareIt (10); writeln(result); //displays "100" writeln(squareIt.xx); //displays "100" writeln(squareIt.y); //error !Cannot find name: y in the PV structure of Lambda squareIt!
Notes and Hints
The scope of variables in nested Lambdas depends upon the following compilation rules: Nested Lambdas do not share either their arguments or their temporary variables. The argument and the temporary variables are always limited in scope to the immediate Lambda object. A nested Lambda shares the persistent variables (pvar) and the persistent class variables (cvar) of its parents. When a variable reference is encountered, the Estimator compiler first searches the local Lambda's temporary variables (var), then the persistent variable structure (pvar), then the persistent class structure (cvar), and finally the global variables.
Also note: Any variable that is used without explicit declaration is automatically declared as a global variable. (This is true even if it is used inside a function definition).
The reg statement declares a register variable inside a Estimator program. If a reg statement appears outside a function definition, the variable declaration generates an error message.
The reg statement declares a register variable within an Lambda. This means that the register variable will have a scope for this invocation of the Lambda object. The register variable is created and initialized each time the Lambda is invoked. Although Estimator is a dynamically typed language, the reg allows the programmer to optionally provide hints to the compiler by specifying a type for register declarations. The supported types are: int and float. Specifying a type of int is equivalent to specifying no type information.
Note: If type hints are supplied, the programmer must assure that no other types are saved in the variable.
reg varName
reg varName=init|
reg type varName
reg type varName=init
reg |
Mandatory keyword |
type | int float |
varName |
The name of the register variable |
=init |
Optional argument. If present, the compiler will assign the varName to the value in init. |
When To Use
It is necessary to explicitly declare register variables inside a function using the reg statement. The register variable structure, LambdaName.Rv, (where LambdaName is the name of the instance of the Lambda) is accessible.
Register variables are always allocated and initialized upon entry to a function and released upon exit.
Example1
function zoo (x) { reg int m; m = x; writeln(m); return (m); } var m = 99; result = zoo(7); //displays "7" (accesses the contents of the local variable) writeln(m); //displays "99" (accesses the contents of the global variable) writeln(zoo.m); //error--!Cannot find name: m in the PV structure of Lambda zoo!
The regress command trains a simple linear regression on the specified numeric expression. The regress statement should be the ONLY statement in the Estimator program, and returns the trained simple linear regression Lambda.
regress numericExpression;
regress | Mandatory keyword |
numericExpression | Numeric expression. |
regress exp(x4)*x10;
This will train a simple linear regression model on the numeric expression: exp(x4)*x10.
Note: Inside the numericExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The return statement exits the current function passes a single value to the caller.
return ( value )
value |
Any expression that returns a value. May be embedded in parenthesis |
Returns |
Immediately evaluates the expression, returns the value, and resume execution of the caller function |
When To Use
The return statement is used to leave the current function and return to the caller with a return value.
Example1
function foo (x) { var m; m = x * 2; return (m); // the value of m is returned to the caller } result = foo(7); //result will receive the value of 14
The score statement performs a set of scoring operations on the current row manager. The score statement must be followed by a single command. The score statement supports commands for averaging and totalling rows from the The score statement does not alter the current record view.
score command;
score | Keyword (optional) |
command | score statement command (mandatory). |
score expression;
score | Keyword (mandatory) |
expression | Any valid javaFilter expression including imbedded score statement commands (mandatory). |
score variable=command;
score | Keyword (optional) |
variable | A variable name to receive the finished score. |
= | The javaFilter assignment operator. |
command | score statement command (mandatory). |
Note1: The score statement generates code which assumes that the variable named, XT, contains the GSM row manager which is to be operated upon.
Note2: The score statement may be used as a stand alone statement in a global declaration or inside an existing function. A stand alone select statement is automatically enclosed in the following universal parse tree lambda:
(lambda (XT) (begin ...score statement block...))
The average command averages a numeric expression over each row in the current row manager.
average expression
average | Mandatory keyword |
expression | Numeric expression. |
score average x3;
This will return the average of x3 for the current record view.
Note: Inside the score expression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The averageForAll command averages a numeric expression over ALL rows in the current row manager.
averageForAll expression
averageForAll | Mandatory keyword |
expression | Numeric expression. |
score averageForAll x10;
This will return the average of x10 for all rows in the current row manager.
Note: Inside the score expression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The extract command extracts single or multiple columns of data from the current record view.
extract extractExpression
extract | Mandatory keyword |
extractExpression | Single or multiple column extraction expression. |
extract : spineVectorType : extractExpression
extract | Mandatory keyword |
spineVectorType | The type of the spine vector for this extraction: Integer, Number, Object, or Word (defaults to Object:). |
extractExpression | Single or multiple column extraction expression. |
score extract new('Vector','Number',2,(x1/x2),sin(x4));
This will extract two columns of data, as specified, from all rows in the current record view. The results will be returned as an Object Vector (the missing spineVectorType argument defaults to Object) with exactly as many entries as there are rows in the current record view.
score extract : Number : sin(x4);
This will extract one columns of data, as specified, from all rows in the current record view. The results will be returned as a Number Vector with exactly as many entries as there are rows in the current record view.
Note: Inside the extractExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The total command totals a numeric expression over each row in the current record view.
total expression
total | Mandatory keyword |
expression | Numeric expression. |
score total x5;
This will return the total of x5 for the current record view.
Note: Inside the score expression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The totalForAll command totals a numeric expression over ALL rows in the current row manager.
totalForAll expression
totalForAll | Mandatory keyword |
expression | Numeric expression. |
score totalForAll (x4 / x2);
This will return the total of (x4 / x2) for all records in the current row manager.
Note: Inside the score expression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The select statement performs a set of selection operations on the XT argument (the row manager Lambda containing the set of Number Vectors for the current time period). The select statement may be followed by a single command or by multiple commands. The select statement supports commands for sorting and selecting rows from the current record view (the currently selected rows). The select command only alters the current record view.
select command1; ... commandN;
select | Keyword (optional) |
Command1; | select statement command (mandatory). |
CommandN; | select statement command (optional). |
Note1: All the commands of a single select statement are grouped together into a single block. This is true regardless of whether or not the select keyword is present, and regardless of whether or not the multiple select commands are enclosed in braces.
Note2: The select statement generates code which assumes that the variable named, XT, contains the GSM row manager Lambda which is to be operated upon.
Note3: The select statement may be used as a stand alone
statement in a global declaration or inside an existing function. A stand
alone select statement is automatically enclosed in the following universal
parse tree lambda:
(lambda (XT) (begin ...select statement block...) XT)
Note4: The select statement always automatically converts any element name symbol into a row index reference.
The all command performs a selection operation on the current recordview.
all selectExpression
all | Mandatory keyword |
selectExpression | Select expression. |
select all x4 > 10000;
This will delete all rows from the current record view where x4 is not greater than 10000.
select all (x4/sin(x2)) > .54;
This will delete all rows from the current record view where (x4/sin(x2)) is not greater than .54.
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The bottom command performs a sort on the current row manager, followed by a deletion operation on the current row manager.
bottom sortExpression cutoff
bottom | Mandatory keyword |
sortExpression | Sort expression. |
cutoff | Cut off absolute number or percent. |
select bottom (x10 * x1) 100;
This will delete all rows from the current record view which are not in the top 100 rows of all (x10 * x1).
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The highest command performs a sort on the current row manager, followed by a deletion operation on the current row manager.
highest sortExpression cutoff
highest | Mandatory keyword |
sortExpression | Sort expression. |
cutoff | Cut off absolute number or percent. |
select highest x4 10%;
This will delete all rows from the current record view which are not in the top 10% of all x4.
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The restore command restores the backup view of the current table cursor.
restore
restore | Mandatory keyword |
select restore;
This will restore the all rows view of the current row manager.
The run command performs a select on the current row manager.
run functionCall
run | Mandatory keyword |
functionCall | A Estimator function call expression to a specified select Lambda. |
select run "myEstimator";
This will run the "myEstimator" Estimator Lambda, in the current project, on the current record view.
The slice command performs an ascending sort on the current row manager, followed by a tile operation on the current row manager.
slice sortExpression tileIndex of tileCount
slice | Mandatory keyword |
sortExpression | Sort expression. |
tileIndex | The index of the tile to show. |
of | Mandatory keyword. |
tileCount | The number of tiles. |
select slice (x21 * x2) 42 of 100;
This will retain all rows from the current record view which are in the 42 percentile of (x21 * x2).
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The sort command performs a sort on the current row manager.
sort [direction] sortExpression
sort | Mandatory keyword |
direction | Optional Sort direction: up or down (optional). If sort direction is omitted, the direction is assumed to be up. |
sortExpression | Mandatory Sort expression. |
select sort down x3;
This will sort all rows in the current record view in descending order by x3.
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The top command performs a sort on the current row manager, followed by a deletion operation on the current row manager.
top sortExpression cutoff
top | Mandatory keyword |
sortExpression | Sort expression. |
cutoff | Cut off absolute number or percent. |
select top x4 10%;
This will delete all rows from the current record view which are not in the top 10% of all x4.
Note: Inside the selectExpression, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
An arbitrary number of Estimator statements may be grouped logically by embedding the statements in braces { exp ...}. A statement block such as this may be placed in any position where a single statement is required. Multiple statements in Estimator may be written on a single line as long as a semicolon terminates each statement.
{exp ...}
exp ... |
Any number of expressions to be evaluated |
When To Use
A statement block may be placed in any position where a single statement is required.
Example1
j = 1; if ( j < 10 ) { k = 100; writeln(k);} else { k = -100; writeln(k);}
The svmregress command trains a support vector regression, with a cubic kernel, on the specified numeric expression list. The svmregress statement should be the ONLY statement in the Estimator program, and returns the trained support vector regression Lambda.
svmregress;
svmregress | Mandatory keyword |
svmregress(numericExpression1,numericExpression2,,...,numericExpressionN);
svmregress | Mandatory keyword |
numericExpression1 | Numeric expression. |
numericExpressionN | Numeric expression. |
svmregress(exp(x4),x10);
This will train a support vector regression model, with a cubic kernel, on the numeric expressions: exp(x4) and x10.
Note: Inside the numericExpressions, the name XT refers to the GSM row manager Lambda input argument. The name xv refers to the currently focused record. The names xtime, y, and x1 thru xm, refer to elements within the currently focused record.
The var statement declares a temporary variable inside a Estimator program. The location of the var statement determines the scope the variable. If a var statement appears inside a function definition, the variable is considered local to that function only. If a var statement appears outside a function definition, the variable has global scope.
The var statement declares a temporary variable within an Lambda. This means that the temporary variable will have a scope for this invocation of the Lambda object. The temporary variable is created and initialized each time the Lambda is invoked. Although Estimator is a dynamically typed language, the var allows the programmer to optionally provide hints to the compiler by specifying a type for variable declarations. The supported types are: char, bool, int, float, and obj. Specifying a type of obj is equivalent to specifying no type information.
Note: If type hints are supplied, the programmer must assure that no other types are saved in the variable.
var varName
var varName=init|
var type varName
var type varName=init
var |
Mandatory keyword |
type | obj char bool int float obj text string symbol bitvec fltvec pcdvec stc dir dic matrix nummat vec bitvec numvec intvec objvec |
varName |
The name of the temporary variable |
=init |
Optional argument. If present, the compiler will assign the varName to the value in init. |
When To Use
Since global variables are automatically declared in the LambdaClient environment, it is unnecessary declare global variables. However, it is necessary to explicitly declare temporary variables inside a function using the var statement. The temporary variable structure, LambdaName.Tv, (where LambdaName is the name of the instance of the Lambda) is accessible, as long the Lambda object instance is active.
Temporary variables are always allocated and initialized upon entry to a function and released upon exit.
Example1
function zoo (x) { var m; m = x; writeln(m); return (m); } var m = 99; result = zoo(7); //displays "7" (accesses the contents of the local variable) writeln(m); //displays "99" (accesses the contents of the global variable) writeln(zoo.m); //error--!Cannot find name: m in the PV structure of Lambda zoo!
Notes and Hints
The scope of variables in nested Lambdas depends upon the following compilation rules: Nested Lambdas do not share either their arguments or their temporary variables. The argument and the temporary variables are always limited in scope to the immediate Lambda object. A nested Lambda shares the persistent variables (pvar) and the persistent class variables (cvar) of its parents. When a variable reference is encountered, the Estimator compiler first searches the local Lambda's temporary variables (var), then the persistent variable structure (pvar), then the persistent class structure (cvar), and finally the global variables.
Also note: Any variable that is used without explicit declaration is automatically declared as a global variable. (This is true even if it is used inside a function definition).
The while statement repeats a set of Estimator statements until its condition is false.
while (test) { expr }
while |
Mandatory keyword |
(test) |
An expression that returns a Boolean value |
{expr} |
A set of Estimator statements |
Example1
var int a = 1; while (a < 10) { display (" ", a) ++a }
This will display the following line in the console screen:
1 2 3 4 5 6 7 8 9