Q. What does the ash function do? Why are the small parameters added to big and -1 passed? How it works? What purpose does it serve for binary search?
It performs a bit shift operation, more precisely an arithmetic shift, as explained / presented graphically for the Lisp special case:
> (ash 51 1) 102
When you do this (ash 51 1) it will shift the binary number 51, i.e. 110011 to 1 bit place to the left, and as a result 1100110 that will give you 102 in decimal. (the process of converting binary to decimal is explained in this answer )

Here it adds 0 in the free most right place (named L east S, ignoring B it).
> (ash 51 -1) 25
When you do this (ash 51 -1) it will shift the binary code 51, i.e. 110011 by 1 bit to the right side (a negative value means the opposite direction) and as a result 11001 that will give you 102 in decimal.

Here it discards the excess LSB.
In a specific example of the guss-my-number game illustrated in Land of Lisp, we are interested in halving the range by half or medium. So, (ash (+ *small* *big*) -1)) doubles 100 + 1 = (ash (+ *small* *big*) -1)) to get 50. We can check this as follows:
> (defparameter *small* 1) *SMALL* > (defparameter *big* 100) *BIG* > (defun guess-my-number () (ash (+ *small* *big*) -1)) GUESS-MY-NUMBER > (guess-my-number) 50
It is interesting to note that you can double the value of an integer by shifting left by 1 bit, and (approximately) double it by moving right by 1 bit.
source share