type VAR = identifier
type code = instruction list
type environment = identifier list
type EXPR = environment -> code * environment
fun ADD_OP expr expr' env = DUMMY
fun SUB_
我對ML毫無經驗,而且我無法理解這一點。 開始問題 多態性排序 列表上執行插入排序此函數採用作爲參數的比較功能較少和元素的列表升進行排序。該代碼編譯並運行正常: fun sort(less, nil) = nil |
sort(less, a : : l) =
let
fun insert(a, nil) = a : : nil |
insert(a, b :
這是我的任務。 (http://prnt.sc/aa3gwd) 我一直工作在這其中一個導師,這是我們想出了這麼遠。這 fun mult(a,b) =
let
val product = 0
in
if (a = 0) then
0
else
while a > 0 do
(
product := product +
我有這樣的代碼片段 fun decrement_to_zero r = if !r < 0
then r := 0
else while !r >= 0 do r := !r - 1
從本教程 https://learnxinyminutes.com/docs/standard-ml/ 但我得到這個錯誤: stdIn:1.2-33.9 Error:
這種語言的語法很混亂。 fun bar a =
print (Int.toString a);
0
編譯。不知道爲什麼emacs縮進0。 fun bar a =
print (Int.toString a)
0
引發錯誤。 Error: operator is not a function [tycon mismatch]
operator
在試圖爲SML中的簡單語言創建解釋器時,我努力將字符串轉換爲整數。例如, val someString = " 1.9"
Int.fromString someString
回報: val it SOME 1 : int option
而且,當我嘗試用從中提取的選項類型的值: valOf(Int.fromString someString);
返回: val it = 1 : int