smlnj

    2熱度

    2回答

    我對SML(來自java世界)和我所瞭解的 結構與java類相似&的簽名是java接口。 SML結構中的所有內容都是不可變的。有沒有可能有一個變量的值可以設置? functor Make(M : sig type data val callback : _ end) = struct val cb = M.callback fu

    0熱度

    2回答

    的元組的列表搜索我是很新的SML/NJ和我種的丟失。我一直在努力實施是通過具有一定列出了它的元組的列表中去搜索功能,例如VAL X = [(5,2,[9,8,7]),(3,4,[ 6,5,0]),(11,12,[8,3,1])]。我想我的函數的元組的第一個元素添加到新的名單,一旦有我的目標數量和元組的元素3號之間的匹配。我嘗試了幾個實現,但目前爲止它們都沒有正常工作。 type id = int*

    -1熱度

    1回答

    我有一個我想要解析爲元組列表的字符串列表。 更具體: val strlist = ["1, 2, 3, 'hello', 4, 5, false, 6, [1, 2, 3], [1, 2]", "6, 1, 3, 'world', 4, 5, true, 4, [1, 2], [4, 7, 5]", . . .] : string list 到 val tupl

    0熱度

    3回答

    我想編寫一個樣本函數,該函數接受任何類型的列表,並且僅當列表是一個實數列表時才返回頭元素。 否則,函數應該給出錯誤信息 。 。 。 E r r o r:操作符和操作數不是。 。 。 datatype typeR = Real of real fun head(xs) = case xs of [] => raise List.Empty | Real (x::

    1熱度

    1回答

    那些返回類型的區別是什麼? val fn1 : int −> (int −> (int −> int)) val fn2: (int −> int) −> (int −> int) 這將創建類型的函數 int -> int -> int meaning int -> (int -> int) 是這樣嗎?沒有支架,它們具有相同的含義!

    1熱度

    1回答

    我是新來的SML,並不完全理解我的問題,雖然我確定我有錯。首先,這裏是我測試的兩個簡短功能及其描述。 MakeInterval - 注意到的自然數- [R,(也可用於RP)和自然數噸,並返回的時間間隔[T-R,T + R]。 fun MakeInterval(r,rp,t) = if r + rp < 0 then [] else t-r :: MakeInterval(r-1

    0熱度

    1回答

    我有以下功能: fun IsDivisible(t, t2) = if t mod t2 > 0 then true else false; fun IsDivisibleFilter(ts, t) = List.filter(fn x => IsDivisible(x, t)) ts; fun IsDivisibleMap(ts, ts2) = map(fn x => IsDivisib

    1熱度

    1回答

    我可以使用類型之前的類型和簽名來專門化簽名中的類型嗎?這裏有一個例子: signature A = sig type t type s end 我可以專注A通過以下? signature B = A where type s = t list SML/NJ和Mlton都抱怨t沒有約束。

    0熱度

    1回答

    嗨,我收到以下SML代碼中的編譯錯誤,有人可以幫忙嗎? Error: operator and operand don't agree [UBOUND match] operator domain: 'Z list operand: ''list in expression: null mylist stdIn:4.15-4.24 Error: ope

    1熱度

    1回答

    如何將buf轉換爲sml/nj中的Word8VectorSlice.slice?例如, val msg = "hello\n"; val buf = Byte.stringToBytes msg; (* how to convert to Word8VectorSlice.slice ?*)