I want to built this search:
(A AND B AND C) OR (C AND D AND E)
I'm trying with this code.
.search(['&', '&', (A), (B),(C) , '|', '&','&', (C), (D), (E)])
Any help please? Thanks.
I want to built this search:
(A AND B AND C) OR (C AND D AND E)
I'm trying with this code.
.search(['&', '&', (A), (B),(C) , '|', '&','&', (C), (D), (E)])
Any help please? Thanks.
You can use the AND, OR functions defined inside expression file
Example:
OR([AND([A, B, C]), AND([C, D, E])])
The software seems to use prefix ("polish") notation, so the operator appears before its operands, hence A AND B being written AND A B.
The same then would apply to OR, you'd write A OR B as OR A B. Therefore
(A AND B AND C) OR (C AND D AND E)
would be transcribed to (formatted for clarity)
OR
AND
AND
A
B
C
AND
AND
C
D
E
therefore
|, &, &, A, B, C, &, &, C, D, E
When using polish notation, it can help to transcribe to and from lisp as S-Expressions are basically polish notation with disambiguating brackets (which also allows variable arity). This both makes things clearer (the brackets help a lot and there are lots of editors with lisp support), and it allows evaluating the expressions in a lisp shell which would probably be convenient to get the logic right.
e.g.
(or
(and (and A B) C)
(and (and C D) E))
Note: in all the lisps I know and is n-ary so this is equivalent to
(or
(and A B C)
(and C D E))
however I'd suggest sticking to the binary form as it makes transcribing back and forth much easier.