Inferno Programming Language – Function Reference

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:

OperationOperatorSyntax ExampleResult
Add‘+’3 + 47
Subtract‘-‘3.0 – 21.0
Divide‘/’3.0 / 21.5
Multiply‘*’3.14* recip 3.141.0
Power‘**’1.4** 2.51.9843134832984438
Power (exp,ln)‘exp’ ‘ln’exp (ln 1)1.0
Logs‘log’ ‘logBase’logBase 10 1002.0
Logs (exp,ln)‘exp’ ‘lnln (exp 1)1.0
Square Root‘sqrt’sqrt 1.4251.1941939201359381m
Negation‘let x =’let x = 1425 in -x-1425
Absolute Val‘abs’abs (-14.25)14.25
Modulus‘%’-3 % 52

#

Array Syntax #

A variety of expressions can be used to build complex programs with Array:

ExpressionFunctionExpression ExampleResult
Array.sumCalculates 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.findFirstSomeFinds 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.findLastSomeFinds 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.findFirstAndLastSomeFinds 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 #

ExpressionFunctionExpression ExampleResult
valueAtFind the value of an input stream at a given time.
: {implicit resolution : resolution} ⇒ series of ‘a → time → option of ‘a
valueAt input0 ?now0.7
latestValueFinds the latest value from an input stream.latestValue input00.8
latestValueBeforeFinds the latest value from an input stream before some given time.latestValueBefore ?now input00.8

Data Formatting #

ExpressionFunctionExpression ExampleResult
truncateToCut off decimals after n valuestruncateTo 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:

ExpressionFunctionExpression ExampleResult
Option.mapMaps 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
fromOptionExtracts 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) ? 0A value of the option or the default value, depending on the option
Option.reduceApplies the given binary function to elements of option. Returns the resultOption.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 ExampleResultFunction
0x5 && 0x91Performs a bitwise AND operation on two values.
0x5 XOR 0x63Performs a bitwise XOR operation on two values.
!(toWord16 0x1)65534Performs a bitwise NOT operation on a value.
testBit (setBit 0x0 3) 3vTrueSets a bit in a value and then checks if it is set.
shift 0x1 38Performs a bit shift operation on a value.
fromWord #false0Converts a Boolean value to an integer.

Word Conversion #

Word Conversion Expression ExampleResultFunction
toWord16 #true1Converts a Boolean value to a 16-bit unsigned integer.
toWord16 (toWord64 77)77Converts a 64-bit unsigned integer to a 16-bit unsigned integer.
toWord16 (toWord64 (2**17 + 2))22Converts a large 64-bit unsigned integer to a 16-bit unsigned integer.
toWord32 (toWord64 77)77Converts a 64-bit unsigned integer to a 32-bit unsigned integer
toWord32 (toWord64 (2**33 + 5))5Converts a large 64-bit unsigned integer to a 32-bit unsigned integer.
toWord64 (toWord16 (2**62 + 1))1Converts a large 16-bit unsigned integer to a 64-bit unsigned integer.

Word Size Conversion #

Word Size Conversion Expression ExampleResultFunction
fromWord (toWord64 (2**62))4611686018427387904Converts a large unsigned integer to a signed integer.
fromWord (toWord32 (262 + 231))2147483648Converts a 64-bit unsigned integer to a 16-bit unsigned integer.
fromWord (toWord16 (231 + 23))8Converts a large unsigned integer to a signed integer.

Data Retrieval

Word Size Conversion Expression ExampleResultFunction
valueAt t inputSome valRetrieve an approximate value for a data stream at a given time.
latestValueBefore t inputSome valRetrieve an approximate value for a data stream at a given time.
latestInput inputSome valRetrieve the first value found, which occurred before the default ?now

Powered by BetterDocs