Nodes
Logic Equal Array#
Compares two arrays and returns true if they are equal, false otherwise.
Inputs#
-
a(Array): The first array to compare.- Type: Array
- Default value: Empty array
[]
-
b(Array): The second array to compare.- Type: Array
- Default value: Empty array
[]
Outputs#
result(Boolean): True if the input arrays are equal, false otherwise.
Configuration#
This node has no configuration options.
Usage#
The Logic Equal Array node is used to compare two arrays and determine if they are equal. It returns true if the arrays have the same length and all elements at corresponding indices are equal. Otherwise, it returns false.
To use this node:
- Connect the first array to the
ainput. - Connect the second array to the
binput. - The
resultoutput will emit true if the arrays are equal, false otherwise.
Example#
Here's an example of how to use the Logic Equal Array node in a spell:
{
"nodes": [
{
"type": "data/constant/array",
"id": "array1",
"configuration": {
"value": [1, 2, 3]
}
},
{
"type": "data/constant/array",
"id": "array2",
"configuration": {
"value": [1, 2, 3]
}
},
{
"type": "logic/equal/array",
"id": "equalArrays",
"inputs": {
"a": "array1.value",
"b": "array2.value"
}
},
{
"type": "io/log",
"id": "log",
"inputs": {
"message": "equalArrays.result"
}
}
]
}In this example:
- Two constant arrays
[1, 2, 3]are defined using Data Constant Array nodes. - The arrays are connected to the
aandbinputs of the Logic Equal Array node. - The
resultoutput of the Logic Equal Array node is connected to an IO Log node. - When the spell is run, it will log
trueto the console since the input arrays are equal.
Best Practices#
- Ensure that the arrays you are comparing are of the same data type. Comparing arrays of different types may lead to unexpected results.
- Keep in mind that the order of elements matters.
[1, 2, 3]is not equal to[3, 2, 1].
Common Issues#
- Comparing large arrays can be computationally expensive. If performance is a concern, consider alternative approaches like hashing the arrays first.
- Be cautious when comparing arrays that contain floating-point numbers, as minor precision differences can cause equality checks to fail.