如何在布朗变量和函数之间进行逻辑运算,整数作为Golang中的参数

时间:2016-08-31 12:42:51

标签: function go boolean logical-operators

我想如何进行逻辑操作" OR"在布尔变量和函数调用之间

func Move(x int, y int, m int) int{

if IsvisitedNode(x,y){
var  possiblemove bool
 possiblemove = possiblemove || Move( x+2, y+1, m+1)
 possiblemove = possiblemove || Move( x+2, y-1, m+1)
 possiblemove = possiblemove || Move( x-2, y+1, m+1)
 possiblemove = possiblemove || Move( x-2, y-1, m+1)
 possiblemove = possiblemove || Move( x+1, y+2, m+1)
 possiblemove = possiblemove || Move( x+1, y-2, m+1)
 possiblemove = possiblemove || Move( x-1, y+2, m+1)
 possiblemove = possiblemove || Move( x-1, y-2, m+1)

if possiblemove == true {
 fmt.Println(x,y)

return true
}else{

visithistory[p] && visithistory[q] = false
        return false

        }
        }
        return 1
        }

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

假设您想要将0评估为false,而将任何其他数字评估为true,则可以执行以下操作:

possiblemove = possiblemove || Move( x+2, y+1, m+1) != 0