sml

    -2热度

    1回答

    我一直在寻找这个ML代码,我看到这个声明 fun doSomething (a, b) = if a < b then ?? else ?? ; 什么的“?”在这方面是什么意思?

    1热度

    1回答

    我想写一个SML函数,它有两个参数,第一个是 int,第二个是列表的列表。目标是在第二个参数中的每个列表的前面插入第一个参数。例如,append_to_front(1,[[3,4],[6,8],[]])应返回[[1,3,4],[1,6,8],[1]]。 我的代码: fun append_to_front(a:int, L:int list list) = if L = [] t

    0热度

    1回答

    为什么编译? fun foo (h::t) = h = hd(t); 但这并不 fun foo (h::t) = PolyML.print (h::t); print "\n"; h = hd(t); ? Value or constructor (h) has not been declared Found near =(h, hd(t)) V

    1热度

    1回答

    在Prolog中,您可以激活跟踪模式进行调试。 ML显然没有这样的事情。至少有一个exit()或abort()?当与调试打印语句结合使用时,A sleep()对于从Prolog近似跟踪模式也很有用。

    2热度

    2回答

    我有一个函数可以从2个列表重建树。我在所有分支上返回一个列表,但是我收到了一个我不明白的错误。但我认为它与返回类型有关。 的错误是这样的: Can't unify ''a with ''a list (Type variable to be unified occurs in type) Found near recon (::(preoH, preoT), ::(inoH, ...)) Ex

    2热度

    1回答

    继suggestion使用嵌套结构的递归数据类型就像树一样,我尝试使所述rechaurive datatyep在测试程序中工作,但遇到(又一个,对我来说很神秘)错误。 我的计划是这样的: datatype 'a tree = Leaf of { value : 'a } | Node of { value : 'a, left: 'a tree, right: 'a tree }

    3热度

    2回答

    考虑这个数据类型在标准-ML: datatype 't options = Null | Some of 't 而且我也有这等数据类型: datatype option = Apple | Orange | Melon 我想指定datatype options应该只接受datatype option作为其输入型't。这个怎么做?

    1热度

    2回答

    我写了一个应该接收元组列表的函数。我访问的元组的部件与#和代码编译: fun recheck ([], n) = [] | recheck (h::t, n) = if ((#1 h) * (#1 h)) + ((#2 h) * (#2 h)) = n then h::recheck(t, n) else recheck(t, n) 但是,基本

    2热度

    1回答

    我有一个正在正确工作的函数... 但是,不幸的是在显示它之前构造了一个很大的字符串。 我想显示每个字符串,而不是直接concatening人,但我不知道该怎么办呢? 下面是函数: fun getBlocked w = case BlockingMgr.listBlockedSuccessors w of nil => "" | ws => concat (

    0热度

    1回答

    我有像下面的SML代码。 fun fact(n) = let fun f(n,g) = if n=0 then g(1) else f(n-1, fn x=>g(x)*n) in f(n, fn x=> x) end; 我想知道我的代码中需要多少空间来计算fact(n)。 它是否需要O(n)?我不完全清楚。