use*_*318 4 scala functional-testing
我一直试图运行这段代码,但不知何故已经出现'单位不匹配,布尔预期错误'.我已经在Stackoverflow上遇到了各种问题,但没有找到任何具体的问题来回答我的问题.
def balance(chars: List[Char]): Boolean =
{
var i = 0;
var j = 0;
if (Count(i, j) == 0){
true
}
else{
false
}
def Count(count: Int, Pos: Int): Int =
{
if (Pos == chars.length)
{
count
}
else
{
if (chars(Pos) == '(')
{
Count(count + 1, Pos + 1);
}
else
{
Count(count - 1, Pos + 1);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)