and()
This function checks if all values received are true.
If they are, the function returns true.
Otherwise, the function returns false.
Acceptable parameter types
-
INT:INTtype parameters must be 1 or 0. 1 means true and 0 means false. -
BOOL-
True:
TRUE,True,true, 1 -
False:
FALSE,False,false, 0
-
Return value
-
Returns 1 if all input values are 1. Returns 0 if one input value is 0.
-
Returns boolean
TRUEif all input values areTRUE,True, ortrue. Returns booleanFALSEif one input value isFALSE,False, orfalse.
Example
If we have the following data in a CSV file of the different pass/fail results of tests taken by students.
To give a student vertex a result attribute of value true, all of their test results must be true.
Otherwise, the attribute is set to false.
| name | result |
|---|---|
Tommy |
true |
Tommy |
true |
Tommy |
false |
Amy |
true |
Amy |
true |
Amy |
true |
We can use the and() reduce function to load the boolean attribute:
LOAD f TO VERTEX Person
VALUES ($"name", REDUCE(and($"result"))
After loading, Tommy has a result of false and Amy has a result of true.