Skip to main content

Module: Expressions

The

Expressions module facilitates creation of statically typed functional data Expression's, as well as providing a set of standard libraries for common Expression patterns.

Example

// Given a `set` of `key`s, calculate the sum of the corresponding values in
// an integer dictionary `dict`
Count: Reduce(
set,
(previous, key) => Add(previous, Get(dict, key),
Const(0n)
)

Example

 // ...
// if name is null, replace with 'Unknown' string
Wage: Let(
Max(0, Subtract(Variable("Hours", FloatType), 8),
overtime => Add(
Multiply(
Variable("NormalRate", FloatType),
Subtract(Variable("Hours", FloatType), overtime)
),
Multiply(
Variable("OvertimeRate", FloatType),
overtime
)
)
),
// ...

Aggregation

AggregationDefinition

Ƭ AggregationDefinition<T>:

CustomAggregationDefinition<T> | StandardAggregationDefinition<T>

A

AggregationDefinition is either a CustomAggregationDefinition or StandardAggregationDefinition.

Type parameters

NameType
Textends EastType = EastType

CustomAggregationDefinition

Ƭ CustomAggregationDefinition<T, U>: Object

An

CustomAggregationDefinition represents a reduction over rows followed by an optional final transformation.

Type parameters

NameType
Textends EastType = EastType
Uextends EastType = EastType

Type declaration

NameType
aggregation_type"Custom"
finalizerEastFunction<T>
initialEastFunction<U>
inverse_reducerEastFunction<U>
previousVariable<U>
reducerEastFunction<U>
typeT

StandardAggregationDefinition

Ƭ StandardAggregationDefinition<T, U>: Object

A

StandardAggregationDefinition calculates one of a handful of built-in reductions over rows.

Type parameters

NameType
Textends EastType = EastType
Uextends StandardAggregationType = StandardAggregationType

Type declaration

NameType
aggregation_typeU
key?EastFunction
typeT
valueEastFunction

Any

Any(value):

StandardAggregationDefinition<BooleanType>

Create an

AggregationDefinition that returns true if one or more value is true.

Example

 // ...
aggregations: {
// return true if a category value is null
CategoryMissing: fields => Any(IsNull(fields.Category)),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<BooleanType>the value to aggregate

Returns

StandardAggregationDefinition<BooleanType>

the

Any StandardAggregationDefinition


CollectDict

CollectDict<K, T>(key, value):

StandardAggregationDefinition<DictType<K, T>>

Create an

AggregationDefinition to create a dictionary of distinct key-value pairs. If multiple distinct, non-null values exist for a given key, then the value is null for that key.

Example

 // ...
aggregations: {
// collect all non-null HourlyRate's into a dictionary by EmployeeId
HourlyRatePerEmployee: fields => CollectDict(
fields.EmployeeId,
fields.HourlyRate
),
// ...
}

Type parameters

NameType
Kextends StringType
Textends EastType

Parameters

NameTypeDescription
keyEastFunction<K>the dict key value
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<DictType<K, T>>

the

CollectDict StandardAggregationDefinition


CollectDictCount

CollectDictCount(value):

StandardAggregationDefinition<DictType<StringType, IntegerType>>

Create an

AggregationDefinition to create a dictionary of the count of non-null keys

Example

 // ...
aggregations: {
// create a dictionary with the count of products by Category
ProductsPerCategory: fields => CollectDictCount(
fields.Category,
),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<StringType>the dict key value

Returns

StandardAggregationDefinition<DictType<StringType, IntegerType>>

the

CollectDictCount StandardAggregationDefinition


CollectDictMean

CollectDictMean(key, value):

StandardAggregationDefinition<DictType<StringType, FloatType>>

Create an

AggregationDefinition to create a dictionary of the sum of non-null values for key-value pairs.

Example

 // ...
aggregations: {
// create a dictionary with the average of Price per Category
MeanPricePerCategory: fields => CollectDictMean(
fields.Category,
fields.Price
),
// ...
}

Parameters

NameTypeDescription
keyEastFunction<StringType>the dict key value
valueEastFunction<IntegerType | FloatType>the value to aggregate

Returns

StandardAggregationDefinition<DictType<StringType, FloatType>>

the

CollectDictMean StandardAggregationDefinition


CollectDictSum

CollectDictSum<T>(key, value): T extends NullType ?

StandardAggregationDefinition<DictType<StringType, NonNullable<T>>> : StandardAggregationDefinition<DictType<StringType, T>>

Create an

AggregationDefinition to create a dictionary of the sum of non-null values for key-value pairs.

Example

 // ...
aggregations: {
// create a dictionary with the sum of Qty's by Category
QtyPerCategory: fields => CollectDictSum(
fields.Category,
fields.Qty
),
// ...
}

Type parameters

NameType
Textends IntegerType | FloatType

Parameters

NameTypeDescription
keyEastFunction<StringType>the dict key value
valueEastFunction<T>the value to aggregate

Returns

T extends NullType ?

StandardAggregationDefinition<DictType<StringType, NonNullable<T>>> : StandardAggregationDefinition<DictType<StringType, T>>

the

CollectDictSum StandardAggregationDefinition


CollectSet

CollectSet<K>(value):

StandardAggregationDefinition<SetType<K>>

Create an

AggregationDefinition to find the set of the non-null string values of value (which defaults to field).

Example

 // ...
aggregations: {
// collect all non-null Categorie's into a set
Categories: fields => CollectSet(fields.Category),
// ...
}

Type parameters

NameType
Kextends StringType

Parameters

NameTypeDescription
valueEastFunction<K>the value to aggregate

Returns

StandardAggregationDefinition<SetType<K>>

the

CollectSet StandardAggregationDefinition


Count

Count(value?):

StandardAggregationDefinition<IntegerType>

Create an Aggregation to count the number of rows where value is not null.

Example

 // ...
aggregations: {
// count the number of Category's that aren't null
ValidCategories: fields => Count(fields.Category),
// ...
}

Parameters

NameTypeDescription
value?EastFunction<EastType>the value to aggregate

Returns

StandardAggregationDefinition<IntegerType>

the

Count StandardAggregationDefinition


DistinctCount

DistinctCount(value):

StandardAggregationDefinition<IntegerType>

Create an Aggregation to count the number of distinct, non-null values of value.

Example

 // ...
aggregations: {
// count the number of distinct non-null Category's
Categories: fields => DistinctCount(fields.Category),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<EastType>the value to aggregate

Returns

StandardAggregationDefinition<IntegerType>

the

DistinctCount StandardAggregationDefinition


Every

Every(value):

StandardAggregationDefinition<BooleanType>

Create an

AggregationDefinition that returns true if all values are true

Example

 // ...
aggregations: {
// return true if all category values are null
AllCategoriesMissing: fields => Every(
IsNull(fields.Category)
),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<BooleanType>the value to aggregate

Returns

StandardAggregationDefinition<BooleanType>

the

Every StandardAggregationDefinition


FindMaximum

FindMaximum<K, T>(value, key): K extends NullType ? T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>> : StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the key corresponding to the largest, non-null value of value (which defaults to field).

Example

 // ...
aggregations: {
// return Product with the lowest Price
HighestPriceProduct: fields => FindMaximum(
fields.Price,
fields.Product
),
// ...
}

Type parameters

NameType
Kextends EastType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<K>the value to aggregate
keyEastFunction<T>the value to find the minimum of

Returns

K extends NullType ? T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>> : StandardAggregationDefinition<T>

the

FindMaximum StandardAggregationDefinition


FindMinimum

FindMinimum<K, T>(value, key): K extends NullType ? T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>> : StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the smallest, non-null value of value (which defaults to field).

Example

 // ...
aggregations: {
// return Product with the lowest Price
LowestPriceProduct: fields => FindMinimum(
fields.Price,
fields.Product
),
// ...
}

Type parameters

NameType
Kextends EastType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<K>the value to aggregate
keyEastFunction<T>the value to find the minimum of

Returns

K extends NullType ? T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>> : StandardAggregationDefinition<T>

the

FindMinimum StandardAggregationDefinition


Maximum

Maximum<T>(value):

StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the largest, non-null value of value (which defaults to field).

Example

 // ...
aggregations: {
// return the highest Price
MaxPrice: fields => Maximum(fields.Price),
// ...
}

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<T>

the

Maximum StandardAggregationDefinition


Mean

Mean(value):

StandardAggregationDefinition<FloatType>

Create an

AggregationDefinition to find the mean of the non-null values of value (which defaults to field).

Example

 // ...
aggregations: {
// find the mean Qty's
MeanQty: fields => Mean(fields.Qty),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<IntegerType | FloatType>the value to aggregate

Returns

StandardAggregationDefinition<FloatType>

the

Mean StandardAggregationDefinition


Median

Median<T>(value):

StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the median of the non-null values of value (which defaults to field). In case of a tie, the greater number is returned.

Example

 // ...
aggregations: {
// return the middle Price
MedianPrice: fields => Median(fields.Price),
// ...
}

Type parameters

NameType
Textends IntegerType | FloatType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<T>

the

Median StandardAggregationDefinition


Minimum

Minimum<T>(value):

StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the smallest, non-null value of value (which defaults to field).

Example

 // ...
aggregations: {
// return the lowest Price
MinPrice: fields => Minimum(fields.Price),
// ...
}

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<T>

the

Minimum StandardAggregationDefinition


Mode

Mode<T>(value):

StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the most common, non-null value of value (which defaults to field). If a tie is encountered, any one of the most-common values is chosen.

Example

 // ...
aggregations: {
// return the mode of prices
ModalPrice: fields => Mode(fields.Price),
// ...
}

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<T>

the

Mode StandardAggregationDefinition


Span

Span<T>(value):

StandardAggregationDefinition<T>

Create an

AggregationDefinition to find the span of the non-null values of value (which defaults to field), meaning the difference between the largest and smallest values.

Example

 // ...
aggregations: {
// return the Price span
PriceSpan: fields => Span(fields.Price),
// ...
}

Type parameters

NameType
Textends IntegerType | FloatType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

StandardAggregationDefinition<T>

the

Span StandardAggregationDefinition


SparseDictCovariance

SparseDictCovariance(value_expr):

AggregationDefinition<DictType<StringType, DictType<StringType, FloatType>>>

Create an

AggregationDefinition to calculate the covariance of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.

Example

 // ...
aggregations: {
// return the ...
PriceCardCoVariance: fields => SparseDictCovariance(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}

Parameters

NameTypeDescription
value_exprExpression<DictType<StringType, FloatType>>the value to aggregate

Returns

AggregationDefinition<DictType<StringType, DictType<StringType, FloatType>>>

the

SparseDictMean CustomAggregationDefinition


SparseDictMean

SparseDictMean(value_expr):

AggregationDefinition<DictType<StringType, FloatType>>

Create an

AggregationDefinition to calculate the average values of a "sparse" dictionary where missing elements are presumed to have value of zero.

Example

 // ...
aggregations: {
// return the ...
PriceCardAvg: fields => SparseDictMean(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}

Parameters

NameTypeDescription
value_exprExpression<DictType<StringType, IntegerType>>the value to aggregate

Returns

AggregationDefinition<DictType<StringType, FloatType>>

the

SparseDictMean CustomAggregationDefinition


SparseDictSum

SparseDictSum(value_expr):

AggregationDefinition<DictType<StringType, FloatType>>

Create an

AggregationDefinition to calculate the sum of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.

Example

 // ...
aggregations: {
// return the ...
PriceCardTotal: fields => SparseDictSum(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}

Parameters

NameTypeDescription
value_exprExpression<DictType<StringType, FloatType>>the value to aggregate

Returns

AggregationDefinition<DictType<StringType, FloatType>>

the

SparseDictSum CustomAggregationDefinition


SparseDictVariance

SparseDictVariance(value_expr):

AggregationDefinition<DictType<StringType, FloatType>>

Create an

AggregationDefinition to calculate the variance of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.

Example

 // ...
aggregations: {
// return the ...
PriceCardVariance: fields => SparseDictVariance(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}

Parameters

NameTypeDescription
value_exprExpression<DictType<StringType, FloatType>>the value to aggregate

Returns

AggregationDefinition<DictType<StringType, FloatType>>

the

SparseDictMean CustomAggregationDefinition


StdDev

StdDev(value):

StandardAggregationDefinition<FloatType>

Create an

AggregationDefinition to find the standard deviation of the non-null values of value (which defaults to field).

Example

 // ...
aggregations: {
// find the std deviation of Qty's
StdDevQty: fields => StdDev(fields.Qty),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<IntegerType | FloatType>the value to aggregate

Returns

StandardAggregationDefinition<FloatType>

the

StdDev StandardAggregationDefinition


Sum

Sum(value):

StandardAggregationDefinition<IntegerType>

Create an

AggregationDefinition to find the sum of the non-null values of value (which defaults to field).

Example

 // ...
aggregations: {
// sum all Qty's to find the total
TotalQty: fields => Sum(fields.Qty),
// ...
}

Parameters

NameTypeDescription
valueEastFunction<IntegerType>the value to aggregate

Returns

StandardAggregationDefinition<IntegerType>

the

Sum StandardAggregationDefinition


Unique

Unique<T>(value): T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>>

Create an Aggregation to find the unique non-null value of value. If multiple non-null values are encountered, it returns null.

Example

 // ...
aggregations: {
// count the number of unique non-null Category's
Categories: fields => Unique(fields.Category),
// ...
}

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
valueEastFunction<T>the value to aggregate

Returns

T extends NullType ?

StandardAggregationDefinition<T> : StandardAggregationDefinition<Nullable<T>>

the

Unique StandardAggregationDefinition

StdLib

OptionType

Ƭ OptionType<T>: VariantType<{ none: NullType ; some: T }>

Return an EastType for the Option variant with cases "none" (indicating the lack of data) and "some" (indicating the presence of data).

This is an alias for VariantType({ none: NullType, some: type }).

Param

The EastType associated with the "some" case.

See

Some, Unwrap, None, MapOption.

Type parameters

NameType
Textends EastType = EastType

None

Const None: ConstFunction<VariantType<{ none: NullType }>>

An EastFunction containing the "none" case of the Option variant. This is an alias for Const(none).

See

Some, Unwrap, MapOption, OptionType.


Abs

Abs(x): EastFunction<IntegerType>

Return the absolute value of a number or integer Expression.

Parameters

NameType
xExpression<IntegerType>

Returns

EastFunction<IntegerType>


AddAll

AddAll(collection): EastFunction<FloatType>

Add all collection values into a single float or integer Expression.

Parameters

NameType
collectionEastFunction<ArrayType<FloatType>>

Returns

EastFunction<FloatType>


AddDict

AddDict<T>(d1, d2): MapValuesFunction<DictType<StringType, any>>

Add first to second where both are dictionaries.

Remarks

Missing keys between first and second are assumed to have a value of 0.

Example

 // ...
// return the prices by dividing the total amounts by the qtys
NewBalance: AddDict(
Variable('InitialBalance', DictType(StringType, FloatType)),
Variable('Amount', DictType(StringType, FloatType))
),
// ...

Type parameters

NameType
Textends NumericType

Parameters

NameType
d1EastFunction<DictType<StringType, T>>
d2EastFunction<DictType<StringType, T>>

Returns

MapValuesFunction<DictType<StringType, any>>


Ceiling

Ceiling<T>(value, unit): EastFunction<T>

Round datetime value up to a whole time unit ("year", "month", "week", "day", "hour", "minute", "second").

Type parameters

NameType
Textends DateTimeType

Parameters

NameType
valueEastFunction<T>
unitTimeUnit | CalendarUnit

Returns

EastFunction<T>

Ceiling<T>(value, type?): EastFunction<T>

Round number value up to a whole number.

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type?"float"

Returns

EastFunction<T>

Ceiling<T>(value, type?): EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>

Round number value up to nearest integer.

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type?"integer"

Returns

EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>


ConvertFloatDict

ConvertFloatDict(dict): EastFunction<DictType<StringType, IntegerType>>

Convert a float DictType to an integer DictType.

Parameters

NameType
dictEastFunction<DictType<StringType, FloatType>>

Returns

EastFunction<DictType<StringType, IntegerType>>


ConvertIntegerDict

ConvertIntegerDict(dict): EastFunction<DictType<StringType, FloatType>>

Convert an integer DictType to an float DictType.

Parameters

NameType
dictEastFunction<DictType<StringType, IntegerType>>

Returns

EastFunction<DictType<StringType, FloatType>>


DateKey

DateKey(value, unit?): EastFunction<StringType>

Convenience function to convert a datetime into a string for a key, rounding optional.

Parameters

NameType
valueEastFunction<DateTimeType>
unit?TimeUnit | CalendarUnit

Returns

EastFunction<StringType>


DayName

DayName(date): GetFunction<StringType>

Return a Print function to convert a datetime Expression to a day of week name.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

GetFunction<StringType>


DayNameShort

DayNameShort(date): GetFunction<StringType>

Return a Print function to convert a datetime Expression to an abbreviated day of week name.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

GetFunction<StringType>


Default

Default<T>(type): ConstFunction<T>

Create a Const expression with the default value of a given type.

See

DefaultValue

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
typeTthe EastType

Returns

ConstFunction<T>


DefaultValue

DefaultValue<T>(type): ValueTypeOf<T>

Create a Value of a given East type.

Remarks

For nullable types this is null, otherwise numeric types default to zero, Boolean to false, strings, arrays, sets and dictionaries are empty, for variants the first variant type is chosen, and structs are created recursively.

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
typeTthe EastType

Returns

ValueTypeOf<T>


Floor

Floor<T>(value, unit): EastFunction<T>

Round datetime value down to a whole time unit ("year", "month", "week", "day", "hour", "minute", "second").

Type parameters

NameType
Textends DateTimeType

Parameters

NameType
valueEastFunction<T>
unitTimeUnit | CalendarUnit

Returns

EastFunction<T>

Floor<T>(value, type): EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>

Round number value down to nearest integer

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type"integer"

Returns

EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>

Floor<T>(value, type?): EastFunction<T>

Round number value down to a whole number.

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type?"float"

Returns

EastFunction<T>


GetTag

GetTag<Variants, Fs>(value): EastFunction<StringType>

Returns a StringType EastFunction for the VariantType Tag.

Type parameters

NameType
Variantsextends Record<string, EastType>
Fsextends { [K in string | number | symbol]: Function }

Parameters

NameTypeDescription
valueEastFunction<VariantType<Variants>>An EastFunction for the Option variant.

Returns

EastFunction<StringType>


Importance

Importance(domain, range?): EastFunction<StringType>

Convert a number Expression to a magnitude string between ['negligible', 'moderate', 'large'].

Parameters

NameType
domainExpression<FloatType>
range[negligible: number, moderate: number]

Returns

EastFunction<StringType>


IsEmpty

IsEmpty(collection): EastFunction<BooleanType>

Return true if collection has zero elements, or false otherwise.

Parameters

NameType
collectionEastFunction<SetType<StringType> | DictType<StringType, EastType>>

Returns

EastFunction<BooleanType>


IsFriday

IsFriday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Friday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsMonday

IsMonday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Monday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsNotNull

IsNotNull(value): EastFunction<BooleanType>

Return true if value is null or false otherwise.

Parameters

NameType
valueEastFunction<EastType>

Returns

EastFunction<BooleanType>


IsNull

IsNull(value): EastFunction<BooleanType>

Return true if value is null or false otherwise.

Parameters

NameType
valueEastFunction<EastType>

Returns

EastFunction<BooleanType>


IsSaturday

IsSaturday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Saturday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsSunday

IsSunday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Sunday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsThursday

IsThursday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Thursday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsTuesday

IsTuesday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Tuesday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsWednesday

IsWednesday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a Wednesday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsWeekday

IsWeekday(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a weekday.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


IsWeekend

IsWeekend(date): EastFunction<BooleanType>

Return the a boolean function to determine if a datetime Expression falls on a weekend.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<BooleanType>


MapOption

MapOption<T, F>(value, f): EastFunction<

OptionType<ReturnType<F>["type"]>>

Returns an EastFunction to map the data corresponding to the "some" case an Option variant through a function, while leaving the "none" case alone.

See

None, Some, Unwrap, OptionType.

Type parameters

NameType
Textends EastType
Fextends (data: Variable<T>) => EastFunction<EastType>

Parameters

NameTypeDescription
valueEastFunction<OptionType<T>>An EastFunction for the Option variant.
fFA function of data associated with the "some" case returning an EastFunction for the new associated data.

Returns

EastFunction<

OptionType<ReturnType<F>["type"]>>


Max

Max<T, U>(a, b): EastFunction<U>

Return the greater of a and b (note that null and NaN are greater than every other value).

Type parameters

NameType
Textends PrimitiveType
Uextends PrimitiveType

Parameters

NameType
aExpression<U>
bExpression<T>

Returns

EastFunction<U>


Min

Min<T, U>(a, b): EastFunction<U>

Return the lesser of a and b (note that null and NaN are greater than every other value).

Type parameters

NameType
Textends PrimitiveType
Uextends PrimitiveType

Parameters

NameType
aExpression<U>
bExpression<T>

Returns

EastFunction<U>


MonthNameShort

MonthNameShort(date): GetFunction<StringType>

Return a Print function to convert a datetime Expression to an abbreviated month name.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

GetFunction<StringType>


MultiplyDict

MultiplyDict<X, Y>(first, second): EastFunction<DictType<StringType, PromoteType<X, Y>>>

Multiply first by second where both are dictionaries.

Example

 // ...
// return the products revenue by multiplying the prices by the qtys
Amounts: MultiplyDict(
Variable('UnitPrices', DictType(StringType, FloatType)),
Variable('Quantities', DictType(StringType, FloatType))
),
// ...

Type parameters

NameType
Xextends IntegerType | FloatType
Yextends IntegerType | FloatType

Parameters

NameTypeDescription
firstExpression<DictType<StringType, X>>the first Expression to multiply
secondExpression<DictType<StringType, Y>>the second Expression to multiply

Returns

EastFunction<DictType<StringType, PromoteType<X, Y>>>


OptionType

OptionType<T>(type): VariantType<{ none: NullType = NullType; some: T = type }>

Return an EastType for the option variant with cases "none" (indicating the lack of data) and "some" (indicating the presence of data).

This is an alias for VariantType({ none: NullType, some: type }).

See

Some, Unwrap, MapOption, Option.

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
typeTThe EastType associated with the "some" case.

Returns

VariantType<{ none: NullType = NullType; some: T = type }>


PrimaryKey

PrimaryKey(...values): EastFunction<StringType>

Convenience function to convert one or more expressions into a string for a key.

Parameters

NameType
...valuesEastFunction<PrimitiveType>[]

Returns

EastFunction<StringType>


PrintSeperated

PrintSeperated(x, thousands_seperator): EastFunction<StringType>

Print a number with a seperator between the thousands, e.g. 1234 as "1,234"

Parameters

NameType
xExpression<IntegerType | FloatType>
thousands_seperatorstring

Returns

EastFunction<StringType>


PrintTruncatedCurrency

PrintTruncatedCurrency(value): EastFunction<StringType>

Return a comma seperated and rounded currency string from an integer.

Parameters

NameType
valueExpression<IntegerType>

Returns

EastFunction<StringType>

PrintTruncatedCurrency(value): EastFunction<StringType>

Return a comma seperated and rounded currency string from a number.

Parameters

NameType
valueExpression<FloatType>

Returns

EastFunction<StringType>


RandomExponential

RandomExponential(): EastFunction<FloatType>

Return a random number drawn from an exponential distribution.

Returns

EastFunction<FloatType>


RandomKeys

RandomKeys<T>(collection, n): EastFunction<SetType<T>>

Return a random subset of at most n keys from the input collection.

Type parameters

NameType
Textends StringType

Parameters

NameType
collectionEastFunction<DictType<T, EastType>>
nEastFunction<IntegerType>

Returns

EastFunction<SetType<T>>


RandomValues

RandomValues<I>(collection, n): EastFunction<DictType<StringType, I>>

Return a random subset of at most n values from the input collection (using sampling without replacement).

Type parameters

NameType
Iextends EastType

Parameters

NameType
collectionEastFunction<DictType<StringType, I>>
nEastFunction<IntegerType>

Returns

EastFunction<DictType<StringType, I>>


RandomWeibull

RandomWeibull(shape): EastFunction<FloatType>

Return a random number drawn from an exponential distribution.

Parameters

NameType
shapeEastFunction<FloatType>

Returns

EastFunction<FloatType>


Replace

Replace<T, U, V>(value, from, to): EastFunction<T>

Return value unless it equals from, in which case replace it with to.

Type parameters

NameType
Textends PrimitiveType
Uextends PrimitiveType
Vextends PrimitiveType

Parameters

NameType
valueEastFunction<T>
fromExpression<U>
toExpression<V>

Returns

EastFunction<T>


Sigmoid

Sigmoid<T>(x): EastFunction<T>

Return a number EastFunction to peform ...

Type parameters

NameType
Textends FloatType

Parameters

NameType
xEastFunction<T>

Returns

EastFunction<T>


Some

Some<T>(data): NewVariantFunction<VariantType<{ some: T }>>

Returns an EastFunction to construct the "some" case of the Option variant with associated data. This is an alias for NewVariant("some", value).

See

None, Unwrap, MapOption, OptionType, some.

Type parameters

NameType
Textends EastType

Parameters

NameTypeDescription
dataEastFunction<T>An EastFunction containing the associated data.

Returns

NewVariantFunction<VariantType<{ some: T }>>


ToEntries

ToEntries<T>(dict): EastFunction<ArrayType<StructType<{ Key: StringType ; Value: T }>>>

Return a ArrayType EastFunction to convert a dictionary into an array of key & value pairs

Type parameters

NameType
Textends EastType

Parameters

NameType
dictEastFunction<DictType<StringType, T>>

Returns

EastFunction<ArrayType<StructType<{ Key: StringType ; Value: T }>>>


Truncate

Truncate<T>(value, type?): EastFunction<T>

Round number value towards zero to a whole number.

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type?"float"

Returns

EastFunction<T>

Truncate<T>(value, type?): EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>

Round number value towards zero to the nearest integer.

Type parameters

NameType
Textends FloatType

Parameters

NameType
valueEastFunction<T>
type?"integer"

Returns

EastFunction<T extends NullType ? Nullable<IntegerType> : IntegerType>


UnionAll

UnionAll<T>(collection): EastFunction<T>

Union all sets in collection into a single set Expression.

Type parameters

NameType
Textends SetType<StringType>

Parameters

NameType
collectionEastFunction<ArrayType<T> | DictType<StringType, T>>

Returns

EastFunction<T>


Unwrap

Unwrap<T, U>(value, defaultValue): EastFunction<T & U>

Returns an EastFunction to unwrap an Option variant, replacing the "none" case with defaultValue.

See

None, Some, MapOption, OptionType.

Type parameters

NameType
Textends EastType
Uextends EastType

Parameters

NameTypeDescription
valueEastFunction<OptionType<T>>An EastFunction for the Option variant.
defaultValueEastFunction<U>An EastFunction containing the associated data.

Returns

EastFunction<T & U>


WeekDescription

WeekDescription(cycle): EastFunction<StringType>

Return a Print function to convert a cycle Expression to an abbreviated week description.

Parameters

NameType
cycleEastFunction<IntegerType>

Returns

EastFunction<StringType>


WeekOfMonth

WeekOfMonth(date): EastFunction<IntegerType>

Return the number of whole weeks elapsed since the first Monday prior to or of the first day of the month.

Parameters

NameType
dateEastFunction<DateTimeType>

Returns

EastFunction<IntegerType>