我的练习给了我这个作为原始编码。 然后,他们希望我们做一个java实现它。 我以为我现在无法理解它。 这里有一个地方使用了一个变量“n”,它以某种方式将它全部加起来。 这是我真正的问题,除非有更多的可以调试。 我只是想在下周最后一次学习这些东西。 fun f x y =
let
val a = x+1
fun g 0 = 0
| g n =
我写了一个函数来处理异常,如果我们得到了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
有人可以解释一下:“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
我需要编写一个函数,它需要一个列表并将其分成2个列表。第一个列表将保存位于奇数位置的元素,第二个列表保存位于偶数位置的元素。这里是我的尝试,给了我以下警告: 警告:类型乏不是一概而论,因为 值的限制被实例化虚拟类型(X1,X2,...) 如何提高呢? fun splt (lst: int list) =
let
fun splt2 (lst: int list, count:
我想写一个函数接受自定义类myType的值,并返回myType option。不确定我的问题是否与签名,内容或返回值有关。 例如,我试着写以下(它的简化,并没有实际意义): let rec myFunc (t:myType) myType option =
let t2 = myFunc t in
match t2 with
| None -> None
|