You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fun sq(n :: Number): n * n end
modulo-power :: Number, Number, Number -> Number
fun modulo-power(base, exp, n):
if exp == 0:
1
else:
if num-round-even(exp):
num-modulo(sq(modulo-power(base, (exp / 2), n)), n)
else:
num-modulo(base * modulo-power(base, (exp - 1), n), n)
end
end
end
The problem is num-round-even returns a number, and hence can't be used in a test position.
The type error does indeed say
However, note what it highlights:
The Boolean is actually the conditional position. Also, the then-clause has nothing to do with this.
The text was updated successfully, but these errors were encountered:
Here's a full program:
The problem is
num-round-even
returns a number, and hence can't be used in a test position.The type error does indeed say
However, note what it highlights:
The Boolean is actually the conditional position. Also, the then-clause has nothing to do with this.
The text was updated successfully, but these errors were encountered: