I am new to Lisp so this might be so simple but I am curious to know about this in any case.
I am familiar with logical operators like AND and OR but lisp does not seem to behave as expected.
For example, For (and 1 8)
Expected:
1 => 0 0 0 1
8 => 1 0 0 0
(and 1 8) => 0 0 0 0
Received:
So, the answer should have been 0
...but instead it is 8
Questions:
- How is this calculation done in LISP?
- Is Logical operators fundamentally different in LISP?
(logand 1 8)
is 0 – Turmoil1 and 8
is8
in Python, too, and1 && 8
is an error in Java. In C++,1 && 8
istrue
. In Ruby,1 and 8
is1
. In JavaScript,1 && 8
is8
. – Oberg