Comments #
Inferno is a hybrid scripting language created by Plow Technologies, that brings powerful realtime scripting capabilities to applications that use it. Think of inferno as excel scripting for real-time data.
Listed below is Inferno’s syntax rules for various operations:
Commenting Syntax #
Inferno’s comment types include single-line and multi-line commenting:
'//' for single-line comments
'/…/' for multi-line comments
Numeric Literals #
Inferno’s numeric types include integer literals and floating point literals.
Integer literals represent fixed positive or negative integer values that are a nonfractional whole number like 300, 43, 777, -234 etc. (with in the integer range).
Floating point literals represent positive or negative fractional values with decimals like 56.43, 2.66, 1204.99 etc.
Integer and Floating Point Syntax Examples #
3 // integer literal
-3 // negative integer literal
3.0 // floating-point literal
-3.0 // negative floating-point literal
Arithmetic Syntax #
Inferno supports basic arithmetic operations on numeric types meaning that it can be used to perform mathematical calculations such as addition, subtraction, multiplication, and division on numbers. In addition to these basic operations, Inferno also supports more mathematical functions such as logarithms and exponentials. These functions can be useful for more complex calculations.
Here are some examples of basic arithmetic operations and syntax examples in Inferno:
Operation | Operator | Syntax Example | Result |
---|---|---|---|
Add | ‘+’ | 3 + 4 | 7 |
Subtract | ‘-‘ | 3.0 – 2 | 1.0 |
Divide | ‘/’ | 3.0 / 2 | 1.5 |
Multiply | ‘*’ | 3.14* recip 3.14 | 1.0 |
Power | ‘**’ | 1.4** 2.5 | 1.9843134832984438 |
Power (exp,ln) | ‘exp’ ‘ln’ | exp (ln 1) | 1.0 |
Logs | ‘log’ ‘logBase’ | logBase 10 100 | 2.0 |
Logs (exp,ln) | ‘exp’ ‘ln | ln (exp 1) | 1.0 |
Square Root | ‘sqrt’ | sqrt 1.425 | 1.1941939201359381m |
Negation | ‘let x =’ | let x = 1425 in -x | -1425 |
Absolute Val | ‘abs’ | abs (-14.25) | 14.25 |
Modulus | ‘%’ | -3 % 5 | 2 |
#
Array Syntax #
A variety of expressions can be used to build complex programs with Array:
Expression | Function | Expression Example | Result |
---|---|---|---|
Array.sum | Calculates the sum of an array, after filtering out the None values. | Array.sum (Array.keepSomes [Some 3.0, None, Some 4.0]) | 0.7 |
Array.findFirstSome | Finds the first element in an array that is not None. | Array.findFirstSome [None, Some 3.0, None, Some 4.0] | A value that represents the found element. |
Array.findLastSome | Finds the last element in an array that is not None. | Array.findLastSome [None, Some 3.0, None, Some 4.0] | A value that represents the found element. |
Array.findFirstAndLastSome | Finds both the first and last element in an array that is not None. | Array.findFirstAndLastSome [None, Some 3.0, None, Some 4.0] | A tuple of two values, each represents the found element |
Fetching Data From OnPing #
Expression | Function | Expression Example | Result |
---|---|---|---|
valueAt | Find the value of an input stream at a given time. : {implicit resolution : resolution} ⇒ series of ‘a → time → option of ‘a | valueAt input0 ?now | 0.7 |
latestValue | Finds the latest value from an input stream. | latestValue input0 | 0.8 |
latestValueBefore | Finds the latest value from an input stream before some given time. | latestValueBefore ?now input0 | 0.8 |
Data Formatting #
Expression | Function | Expression Example | Result |
---|---|---|---|
truncateTo | Cut off decimals after n values | truncateTo 0 3.1234 truncateTo 1 3.1234 truncateTo 2 3.1234 | 3 3.1 3.12 |
Option Syntax #
A variety of expressions can be used to build complex programs with Option:
Expression | Function | Expression Example | Result |
---|---|---|---|
Option.map | Maps the given function to the value of the option, if it exists. | Option.map (fun x -> x + 2) (Some 4.0) | A value that represents the result of the mapping operation |
fromOption | Extracts the value of an option, or returns the default if option is None. | fromOption 0 (Some 4.0) | A value of the options or the default value, depending on the value. |
Operator “?” | Returns the value of the option if it exists, or default if option is None. | (Some 4.0) ? 0 | A value of the option or the default value, depending on the option |
Option.reduce | Applies the given binary function to elements of option. Returns the result | Option.reduce (fun d -> d + 2) 0.0 (Some 4.0) | A value that represents the result of the reduction operation. |
Bitwise Operations #
Bitwise Operation Expression Example | Result | Function |
---|---|---|
0x5 && 0x9 | 1 | Performs a bitwise AND operation on two values. |
0x5 XOR 0x6 | 3 | Performs a bitwise XOR operation on two values. |
!(toWord16 0x1) | 65534 | Performs a bitwise NOT operation on a value. |
testBit (setBit 0x0 3) 3 | vTrue | Sets a bit in a value and then checks if it is set. |
shift 0x1 3 | 8 | Performs a bit shift operation on a value. |
fromWord #false | 0 | Converts a Boolean value to an integer. |
Word Conversion #
Word Conversion Expression Example | Result | Function |
---|---|---|
toWord16 #true | 1 | Converts a Boolean value to a 16-bit unsigned integer. |
toWord16 (toWord64 77) | 77 | Converts a 64-bit unsigned integer to a 16-bit unsigned integer. |
toWord16 (toWord64 (2**17 + 2)) | 22 | Converts a large 64-bit unsigned integer to a 16-bit unsigned integer. |
toWord32 (toWord64 77) | 77 | Converts a 64-bit unsigned integer to a 32-bit unsigned integer |
toWord32 (toWord64 (2**33 + 5)) | 5 | Converts a large 64-bit unsigned integer to a 32-bit unsigned integer. |
toWord64 (toWord16 (2**62 + 1)) | 1 | Converts a large 16-bit unsigned integer to a 64-bit unsigned integer. |
Word Size Conversion #
Word Size Conversion Expression Example | Result | Function |
---|---|---|
fromWord (toWord64 (2**62)) | 4611686018427387904 | Converts a large unsigned integer to a signed integer. |
fromWord (toWord32 (262 + 231)) | 2147483648 | Converts a 64-bit unsigned integer to a 16-bit unsigned integer. |
fromWord (toWord16 (231 + 23)) | 8 | Converts a large unsigned integer to a signed integer. |
Data Retrieval
Word Size Conversion Expression Example | Result | Function |
---|---|---|
valueAt t input | Some val | Retrieve an approximate value for a data stream at a given time. |
latestValueBefore t input | Some val | Retrieve an approximate value for a data stream at a given time. |
latestInput input | Some val | Retrieve the first value found, which occurred before the default ?now |