PenScript Operators

Operators in PenScript allow you to perform basic mathematical and comparative operations on lists of values. Below are the available operators and how to use them.

:sum

Returns the sum of all numerical values in a list.

{
	":sum": [3, 5, 10]
}

Result: 18
Note: The result is undefined if any element in the list is a string or an object.

:product

Returns the product (multiplication) of all numerical values in a list.

{
	":product": [12, 5]
}

Result: 60

:max

Returns the highest value in a list of numbers or dates.

Numerical Example:

{
	":max": [12, 5]
}
{
    ":max": [
        { ":date": "2022-12-01" },
        { ":date": "2022-01-01" }
    ]
}

Result: 12

Date Example:

{
    ":max": [
        { ":date": "2022-12-01" },
        { ":date": "2022-01-01" }
    ]
}

Result: 2022-12-01

:min

Returns the lowest value in a list of numbers or dates.

{
	":min": [12, 5]
}
{
    ":min": [
        { ":date": "2022-12-01" },
        { ":date": "2022-01-01" }
    ]
}

Result: 5

The function supports both integers and date formats.

:increasing

Returns true if the second value in the list is higher than the first value. If the second value is less than or equal to the first, it returns false.

{
	":increasing": [12, 5]
}

Result: false
Explanation: Since 5 is not greater than 12, the result is false.


These operators are foundational tools in PenScript, enabling you to handle calculations and comparisons easily within your workflows. Use them to simplify complex operations and automate your logic!


What’s Next