sml

    1热度

    2回答

    我只是想知道什么是XL变量在这里,它没有在任何地方声明?如果字符串不在列表中,此函数返回NONE。否则,返回原始字符串列表,但没有匹配字符串。 fun same_string(s1 : string, s2 : string) = s1 = s2 fun all_except_option(s1: string, lst: string list) = case lst o

    1热度

    1回答

    我写了一个函数,它可以计算一个由实数列表构成的多项式的x的值。 infixr 5 ^^; fun (x:real) ^^ 0 = 1.0 | (x:real) ^^ n = x*(x^^(n-1)); fun poly [] (x:real) = 0.0 | poly (hd::tl) (x:real) = hd*(x^^(length tl)) + poly tl x

    0热度

    1回答

    有人可以解释一下:“g的描述”吗? f1如何取得单位并返回一个int &其余的我也很困惑! (* Description of g: * g takes f1: unit -> int, f2: string -> int and p: pattern, and returns * an int. f1 and f2 are used to specify what number to be

    0热度

    2回答

    我需要编写一个函数,它需要一个列表并将其分成2个列表。第一个列表将保存位于奇数位置的元素,第二个列表保存位于偶数位置的元素。这里是我的尝试,给了我以下警告: 警告:类型乏不是一概而论,因为 值的限制被实例化虚拟类型(X1,X2,...) 如何提高呢? fun splt (lst: int list) = let fun splt2 (lst: int list, count:

    3热度

    1回答

    我想理解这两者之间的区别; val my_fun = length o List.filter (fn (item) => item = #"a") o String.explode 这一个可以调用(my_fun“名称”将返回1),并正常工作。我想了解的功能组成的,为什么下面不工作 length o (List.filter (fn (item) => item = #"a") (String

    2热度

    1回答

    我写了一个函数来处理异常,如果我们得到了R2 = 0,I2 = 0,但是当我运行程序我得到这个错误: operatii.ml:12: error: Type error in function application. Function: = : ''a * ''a -> bool Argument: (r2, 0.0) : real * real Reason: C

    2热度

    1回答

    为什么1.0 = 2.0不工作?是不是真的一个平等的类型? 它给人的错误: Error: operator and operand don't agree [equality type required] operator domain: ''Z * ''Z operand: real * real in expression: 1.0 = 2.0

    0热度

    1回答

    带有不可见和可见组件的ML模块删除矩阵的第一列和最后一列。 矩阵存储为列表清单,如下所示: | 4 | 5 | 6 | 7 | | 8 | 9 | 10 | 11 | | 12 | 13 | 14 | 15 | =>是4×4阵列 上面的矩阵将被存储为 val mat = [[4,5,6,7],[8,9,10,11],[12,13,14,15] ]。 我需要使用地图功能。 样品试验: VAL垫= [

    0热度

    1回答

    所以我有2个文件,file1.sml & file2.sml都有正确的代码&我使用的是Windows。 当我运行emacs并执行时:使用“file1.sml”它运行良好,但是当我简单地转到选项卡File-> Close以关闭文件,然后将file2.sml拖入emacs并尝试运行它以同样的方式,它使这个错误: [使用失败:IO:openIn失败的 “file2.sml”,Win32TextPrimI

    0热度

    1回答

    所以我有一个数据类型: datatype ex = A of int | B of ex * ex; 和实例变量: val x = (B (A 1, B (A 2, A 3))); 我想通过它来打印这样的: "(1, (2, 3))" 任何帮助将是不胜感激!谢谢。