我正在設置一個函數,它將模擬循環,直到滿足條件。 我的總體計劃是使用遞歸,但我試圖首先獲得基礎知識。 我得到了一個基本的函數,使用If語句來查看X的值是什麼。我打算使用遞歸來將X用作計數器,但我會在稍後討論它。 我現在主要關心的是,看來我只能在「then」語句後執行1個命令。 fun whileloop (x,a) =
if (x<4)
then a+1
else a
我很新的SML和我想要一些項目添加到列表中 fun foo(inFile : string, outFile : string) = let
val file = TextIO.openIn inFile
val outStream = TextIO.openOut outFile
val contents = TextIO.inputAll file
val lines = String
我想從我在SML中編寫的python文件調用函數。我收到tycon不匹配錯誤,我不明白爲什麼。這是我的SML碼 fun interpreter(inFile: string, outFile: string)=
let
val s = interpreter(inFile, outFile)
in
OS.Process.system ("python interpreter
我想在SML中編寫一個函數,它搜索字符串的元組列表,並且如果它在元組的第一個元素中找到字符串,則返回第二個元素。 fun getFromBlist (name : command, (x,y)::tail : (command*command) list) =
if x = name then y else getFromBlist(name, tail)
| getFromB