AND and OR in conditionals?

Tried to find if AND and OR are supported in conditionals in Q.

I just tried to type in:

   and

and get response:

   &

also tried:

   or

and got response: 

   |

However when I enter:

   1 | 2

i get response:

   2

So it seems to return the maximum of the two numbers

Also & seems to retrun the minimum.

What is the meaning / background?

It makes sense to me. OR requires any booleans to be true to pass, so taking the max of the booleans is the same logic.

q)0b|1b

1b

q)max 01b

1b

AND requires all booleans to be true to pass, so taking the min of booleans is also the same logic.

q)0b&1b

0b

q)min 01b

0b

It is mentioned on wiki page that ‘|’ behaves as max and ‘&’ as min.

http://code.kx.com/wiki/Reference/Bar
http://code.kx.com/wiki/Reference/Ampersand

The background is that the boolean cases are essentially the degenerate cases (as demonstrated above)  so recognizing that the domain of & and | have been elegantly extended to all integers.  This behavior started in various dialects of APL, then J & K, and now Q.  It’s a good extension but it’s not new.

Thx. Had some difficulty to find the right docs and thus missed those implications ;-)

2015-07-13 17:26 GMT+02:00 RAHUL ASATI <rahul.asati04@gmail.com>:

It is mentioned on wiki page that ‘|’ behaves as max and ‘&’ as min.

http://code.kx.com/wiki/Reference/Bar
http://code.kx.com/wiki/Reference/Ampersand