Operators
Introduction to Operators in Flowata
Operators are the building blocks that enable you to perform various types of operations in Flowata, from simple arithmetic calculations to complex logical evaluations. Understanding operators is crucial for writing efficient and effective formulas. In Flowata, you'll find a rich set of operators that are designed to be both powerful and intuitive.
This document will guide you through the different categories of operators available in Flowata:
- Concatenation: Find out how to join strings together to create meaningful text.
- Arithmetic Operators: Learn how to perform basic mathematical operations like addition, subtraction, multiplication, and division.
- Comparison Operators: Understand how to compare values and make decisions based on those comparisons.
- Logical Operators: Discover how to evaluate multiple conditions and make logical decisions in your formulas.
Whether you're a beginner looking to understand the basics or an experienced developer seeking to optimize your formulas, this guide will provide you with the insights you need to make the most out of Flowata's operator set.
Concatenation
The concat
function or the &
operator can be used to concatenate strings.
print(concat("Hello", " ", "world!")); // Output: Hello world!
print("Hello" & " " & "world!"); // Output: Hello world!
Arithmetic Operators
Flowata provides both word-based functions and operator symbols for arithmetic operations.
Word-based functions:
add(arg1, arg2, ...)
subtract(arg1, arg2)
multiply(arg1, arg2)
divide(arg1, arg2)
modulo(a, b)
power(base, exponent)
Operator symbols:
+
(addition)-
(subtraction)*
(multiplication)/
(division)^
(exponentiation)
print(add(2, 3)); // Output: 5
print(subtract(10, 4)); // Output: 6
print(multiply(5, 2)); // Output: 10
print(divide(15, 3)); // Output: 5
print(modulo(10, 3)); // Output: 1
print(power(2, 3)); // Output: 8
print(2 + 3); // Output: 5
print(10 - 4); // Output: 6
print(5 * 2); // Output: 10
print(15 / 3); // Output: 5
print(10 % 3); // Output: 1
print(2 ^ 3); // Output: 8
Comparison Operators
Flowata provides both word-based functions and operator symbols for comparison operations.
Word-based functions:
greaterThan(arg1, arg2)
lessThan(arg1, arg2)
greaterEqual(arg1, arg2)
lessEqual(arg1, arg2)
equals(arg1, arg2)
notEquals(arg1, arg2)
Operator symbols:
>
(greater than)<
(less than)>=
(greater than or equal to)<=
(less than or equal to)==
(equals)!=
(not equals)
print(greaterThan(5, 3)); // Output: true
print(lessThan(7, 4)); // Output: false
print(greaterEqual(8, 8)); // Output: true
print(lessEqual(10, 12)); // Output: true
print(equals("hello", "world")); // Output: false
print(notEquals(5, 5)); // Output: false
print(5 > 3); // Output: true
print(7 < 4); // Output: false
print(8 >= 8); // Output: true
print(10 <= 12); // Output: true
print("hello" == "world"); // Output: false
print(5 != 5); // Output: false
Logical Operators
Flowata provides both word-based functions and operator symbols for logical operations.
Word-based functions:
and(arg1, arg2)
or(arg1, arg2)
not(arg)
Operator symbols:
&&
(logical and)||
(logical or)!
(logical not)
print(and(true, false)); // Output: false
print(or(true, false)); // Output: true
print(not(true)); // Output: false
print(true && false); // Output: false
print(true || false); // Output: true
print(!true); // Output: false
Index Accessors
Index accessors are a powerful tool in Flowata that allow you to directly access specific elements within arrays, objects, and other data structures. Unlike the dotPath
function, when using index accessors directly, you can utilize variables and string keys without any special formatting.
Using Index Accessors with Arrays
For arrays, you can access elements by their position:
setLocal(myArray, [10, 20, 30, 40]);
print(myArray[2]); // Output: 20
If you have a variable that holds a position, you can use it directly:
setLocal(position, 3);
print(myArray[position]); // Output: 30