or
is looking for the first truthy value, checking arguments from left to right. Every value other than #false
is truthy. If any is found, it's returned. In your example, '(1 2)
is the first truthy value from the left, so it's returned.
Or
called with no arguments returns #false
, because no truthy values were found:
> (or)
#f
And
checks whether all values are truthy, so it has to examine all of them, going from left to the right, and it can return #false
(if any #false
is found) or, if all values are truthy, last of them. In your example, '(1 3)
is the last truthy value, so it's returned.
And
called with no arguments returns #true
, because no #false
was found:
> (and)
#t
Read also the docs about or
and and
.
By the way, there is a difference between '
and `
. First one is quote
, the second one is quasiquote
. In this very example, it doesn't matter, but you should know the difference between them.
And if you were really looking for union function, check racket/set
library:
(require racket/set)
(set-union (set 1 2) (set 1 3))
=> (set 1 3 2)