|
|
|
|
|
by S4M
3772 days ago
|
|
I can somewhat make sense of that code, but the code of function ch-hof is a bit hard to read - and the function name is not helping. I guess he's trying to see if the king is under check, and if so by which piece(s). Also I notice code like: (- (cdr kpos) 1))
How is that possible? If kpos is a list of two elements to represent the king's position, so (cdr kpos) should be a list, not compatible with subtraction.For example: #;4> (- (cdr '(1 2)) 1)
Error: (-) bad argument type: (2)
|
|
After looking carefully, the kpos is the result of the function find. In this case it's a cons with the row and the column of the king. So the code that runs is more like
In this case, for clarity I prefer to use a struct instead of a cons to save the position