Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

A draft specification is available in the BASE component, see here.

This page is for discussion on this Rules language, including built-in and plug-in functions, operators and value referencing.

Built-in Functions

Current list of built-in functions

DIPS Function list

3.1. Logical functions

Table 3. Logical functions

Function

Description

AND(logical1, [logical2], …)

Returns TRUE if all of its arguments are TRUE

OR(logical1,logical2,…)

Returns TRUE if any argument is TRUE

NOT(logical)

Reverses the logic of its argument

IF(logical_test, value_if_true, [value_if_false])

Specifies a logical test to perform

TRUE()

Returns the logical value TRUE.

FALSE()

Returns the logical value FALSE.

3.2. Math and trigonometry functions

Table 4. Math and trigonometry functions

Function

Description

ABS(number)

Returns the absolute value of a number. The absolute value of a number is the number without its sign.

ACOS(number)

Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is number. The returned angle is given in radians in the range 0 (zero) to pi.

ASIN(number)

Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is number. The returned angle is given in radians in the range -pi/2 to pi/2.

ATAN (number)

Returns the arctangent, or inverse tangent, of a number. The arctangent is the angle whose tangent is number. The returned angle is given in radians in the range -pi/2 to pi/2.

ATAN2(x_num,y_num)

Returns the arctangent, or inverse tangent, of the specified x- and y-coordinates. The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a point with coordinates (x_num, y_num). The angle is given in radians between -pi and pi, excluding -pi.

CEILING(number,significance)

Returns number rounded up, away from zero, to the nearest multiple of significance. For example, if you want to avoid using pennies in your prices and your product is priced at $4.42, use the formula =CEILING(4.42,0.05) to round prices up to the nearest nickel.

COS(number)

Returns the cosine of the given angle.

COSH(number)

Returns the hyperbolic cosine of a number.

EXP(number)

Returns e raised to the power of number. The constant e equals 2.71828182845904, the base of the natural logarithm.

FLOOR(number,significance)

Rounds number down, toward zero, to the nearest multiple of significance.

INT(number)

Rounds a number down to the nearest integer.

LN(number)

Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904).

LOG(number,[base])

Returns the logarithm of a number to the base you specify.

LOG10(number)

Returns the base-10 logarithm of a number.

PI()

Returns the number 3.14159265358979, the mathematical constant pi, accurate to 15 digits.

POWER(number,power)

Returns the result of a number raised to a power.

RAND()

Returns an evenly distributed random real number greater than or equal to 0 and less than 1. A new random real number is returned every time the worksheet is calculated.

RANDBETWEEN(bottom,top)

Returns a random integer number between the numbers you specify. A new random integer number is returned every time the worksheet is calculated.

ROUND(number, [num_digits])

The ROUND function rounds a number to a specified number of digits.

SIGN(number)

Determines the sign of a number. Returns 1 if the number is positive, zero (0) if the number is 0, and -1 if the number is negative.

SIN(number)

Returns the sine of the given angle.

SINH(number)

Returns the hyperbolic sine of a number.

SQRT(number)

Returns a positive square root.

SUM(number1, [number2], [number3], [number4], …)

The SUM function adds all the numbers that you specify as arguments.

TAN(number)

Returns the tangent of the given angle.

TANH(number)

Returns the hyperbolic tangent of a number.

TRUNC(number,num_digits)

Truncates a number to an integer by removing the fractional part of the number.

3.3. Text functions

Table 5. Text functions

Function

Description

CHAR(number)

Returns the character specified by a number. Use CHAR to translate code page numbers you might get from files on other types of computers into characters.

CODE(text)

Returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer.

CONCATENATE(text1, [text2], …)

The CONCATENATE function joins up to 255 text strings into one text string. The joined items can be text, numbers, cell references, or a combination of those items. For example, if your worksheet contains a person’s first name in cell A1 and the person’s last name in cell B1, you can combine the two values in another cell by using the following formula:=CONCATENATE(A1," ",B1)

FIND(find_text,within_text,start_num)

FIND locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.

LEFT(text,num_chars)

LEFT returns the first character or characters in a text string, based on the number of characters you specify.

LEN(text)

LEN returns the number of characters in a text string.

LOWER(text)

Converts all uppercase letters in a text string to lowercase.

MID(text,start_num,num_chars)

MID returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.

PROPER(text)

Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter. Converts all other letters to lowercase letters.

REPLACE(old_text,start_num,num_chars,new_text)

REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string.

REPT(text,number_times)

Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string.

RIGHT(text,num_chars)

RIGHT returns the last character or characters in a text string, based on the number of characters you specify.

SEARCH(find_text, within_text, [start_num])

The SEARCH and SEARCHB functions locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. For example, to find the position of the letter "n" in the word "printer", you can use the following function: =SEARCH("n","printer") This function returns 4 because "n" is the fourth character in the word "printer."

SUBSTITUTE(text,old_text,new_text,instance_num)

Substitutes new_text for old_text in a text string. Use SUBSTITUTE when you want to replace specific text in a text string; use REPLACE when you want to replace any text that occurs in a specific location in a text string.

T(value)

Returns the text referred to by value.

TEXT(value, [format_text])

The TEXT function converts a numeric value to text and lets you specify the display formatting by using special format strings.

TRIM(text)

Removes all spaces from text except for single spaces between words. Use TRIM on text that you have received from another application that may have irregular spacing.

UPPER(text)

Converts text to uppercase.

VALUE(text)

Converts a text string that represents a number to a number.

3.4. Statistical functions

Table 6. Statistical functions

Function

Description

AVERAGE(number1, [number2],…)

Returns the average (arithmetic mean) of the arguments.

AVERAGEA(value1,value2,…)

Calculates the average (arithmetic mean) of the values in the list of arguments.

COUNT(value1, [value2],…)

The COUNT function counts the number of vaues that contain numbers, and counts numbers within the list of arguments.

COUNTA(value1, [value2], …)

The COUNTA function counts the number of values that are not empty in a range.

COUNTBLANK(value1, [value2], …)

Counts empty values in a specified range of values.

COUNTIF(value1, [value2], …, ">2")

The COUNTIF function counts the number of values within a range that meet a single criterion that you specify

MAX(number1,number2,…)

Returns the largest value in a set of values.

MAXA(value1,value2,…)

Returns the largest value in a list of arguments.

MIN(number1,number2,…)

Returns the smallest number in a set of values.

MINA(value1,value2,…)

Returns the smallest value in the list of arguments.

STDEV(number1,number2,…)

Estimates standard deviation based on a sample. The standard deviation is a measure of how widely values are dispersed from the average value (the mean).

STDEVA(value1,value2,…)

Estimates standard deviation based on a sample. The standard deviation is a measure of how widely values are dispersed from the average value (the mean).

STDEVP(number1,number2,…)

Calculates standard deviation based on the entire population given as arguments. The standard deviation is a measure of how widely values are dispersed from the average value (the mean).

STDEVPA(value1,value2,…)

Calculates standard deviation based on the entire population given as arguments, including text and logical values. The standard deviation is a measure of how widely values are dispersed from the average value (the mean).

VAR(number1,number2,…)

Estimates variance based on a sample.

VARA(value1,value2,…)

Estimates variance based on a sample.

VARP(number1,number2,…)

Calculates variance based on the entire population.

VARPA(value1,value2,…)

Calculates variance based on the entire population.

3.5. Date and time functions

Table 7. Date and time functions

Function

Description

NOW()

Returns the datetime that represent the current date and time.

TODAY()

Returns the datetime that represent the current date.

NOWTICKS()

Returns the number of ticks that represent the current datetime.

TODAYTICKS()

Returns the number of ticks that represent the current date.

DATEVALUE(date_text)

The DATEVALUE function converts a date or datetime that is stored as string to ticks.

DAYTICKS(days)

The DAYTICKS function converts days to ticks.

HOURTICKS(hours)

The HOURTICKS function converts hours to ticks.

MINUTETICKS(minutes)

The MINUTETICKS function converts hours to ticks.

DATETIME(ticks)

The DATETIME function converts ticks to datetime.

ISO8601DATETIME(ticks)

The ISO8601DATETIME function converts ticks to iso8601 datetime string.

ISO8601DATE(ticks)

The ISO8601DATE function converts ticks to iso8601 date string.

ISO8601TIME(ticks)

The ISO8601TIME function converts ticks to iso8601 time string.

WEEKNUM(ticks)

Returns the week of the year that includes the date in the specified datetime value represented by ticks.

DURATIONTICKS(duration_text)

The DURATIONTICKS function converts iso8601 duration text to ticks.

DAYS(end_date, start_date)

Returns the number of days between two dates.

HOURS(end_date, start_date)

Returns the number of hours between two dates.

WEEKS(end_date, start_date)

Returns the number of weeks between two dates.

MONTH(ticks)

Returns the month of a date represented by ticks. The month is returned as an integer, ranging from 1 (January) to 12 (December).

YEAR(ticks)

Returns the year of a date represented by ticks. The year is returned as an integer in the range 0001-9999.

3.6. Information functions

Table 8. Information functions

Function

Description

ISBLANK(value)

Value refers to an empty value.

ISNUMBER(value)

Value refers to a number.

 

Rules in Archetypes - natural language

Archetypes currently use no language-dependent symbols, other than the adl language keywords ('archetype', 'description', 'definition' etc). But if we add rules in a typical programming language fashion, we get language-dependency, like this:

rules
	$map_value: Real := /data[id2]/events[id7]/data[id4]/items[id1007]/value/magnitude
	$sys_bp_val: Real := /data[id2]/events[id7]/data[id4]/items[id5]/value/magnitude
	$dia_bp_val: Real := /data[id2]/events[id7]/data[id4]/items[id6]/value/magnitude

	mean_arterial_pressure: $map_value = $dia_bp_val + 0.33 * ($sys_bp_val - $dia_bp_val)

	$pulse_pressure_val: Real := /data[id2]/events[id7]/data[id4]/items[id1008]/value/magnitude

	pulse_pressure: $pulse_pressure_val = $sys_bp_val - $dia_bp_val

Here, the variables '$map_value' etc are all in English; so are the assertion tags 'mean_arterial_pressure' and 'pulse_pressure'. To make this language-independent, we would need to do something like this:

rules
	$[rv1]: Real := /data[id2]/events[id7]/data[id4]/items[id1007]/value/magnitude
	$[rv2]: Real := /data[id2]/events[id7]/data[id4]/items[id5]/value/magnitude
	$[rv3]: Real := /data[id2]/events[id7]/data[id4]/items[id6]/value/magnitude

	[rt1]: $[rv1] = $[rv3] + 0.33 * ( $[rv2] - $[rv3] )

	$[rv4]: Real := /data[id2]/events[id7]/data[id4]/items[id1008]/value/magnitude

	[rt2]: $[rv4] = $[rv2] - $[rv3]
 
terminology
	term_definitions = <
		["en"] = <
			...
			["rv1"] = <
				text = <"map_value">
				description = <"MAP value variable">
			>
			["rv2"] = <
				text = <"sys_bp_val">
				description = <"Systolic BP value variable">
			>
			["rv3"] = <
				text = <"dia_bp_val">
				description = <"Diastolic BP value variable">
			>
			["rv4"] = <
				text = <"pulse_pressure_val">
				description = <"Pulse pressure value variable">
			>
			["rt1"] = <
				text = <"mean_arterial_pressure">
				description = <"MAP assertion tag">
			>
			["rt2"] = <
				text = <"pulse_pressure">
				description = <"Pulse pressure assertion tag">
			>

		>
		["es"] = <
			...
		>
	>
	

In this approach, we are adding new kinds of terms 'rv' = rule variable, 'rt' = rule tag. The implication is that textual substitution of 'rv1' by 'map_value' etc would be done in a GUI tool, and optionally before passing the rules text to an evaluator.

This is perhaps overkill - but it does preserve archetype language independence.

 

  • No labels