1
I'm trying to get a number from a user. That number is then used to call another function
randomList(n)
which takes the given number and uses it. I keep getting the errorexception option
. I've read that adding SOME to the variable declaration or valOf can fix this issue, but it is not working for me. What do I need to change?如何獲得一個整數作爲用戶輸入的SML
fun getNumber() =
print "Please enter the number of integers: ";
let
val str = valOf (TextIO.inputLine TextIO.stdIn)
val i : int = valOf (Int.fromString str)
in
randomList(i)
end;
getNumber();
當運行代碼我得到的錯誤:'錯誤:運營商是不是一個函數[tycon不匹配] 操作者:單元 在表達式:(印刷 「請輸入整數的個數:」 讓VAL = VAL = i' –
XXIV
我還嘗試添加';'和函數括號的結尾,但是這又給我錯誤'異常選項'再次 – XXIV
是的,';'在函數parens的末尾丟失。 –