List SML创建列表操作数不匹配的列表

List SML创建列表操作数不匹配的列表,list,sml,type-mismatch,operand,List,Sml,Type Mismatch,Operand,我试图创建一个列表列表,这意味着我的结果应该是 thatgraph = [[0,[1,2]],[1,[1,3],[1,4],[1,5]],[2,[3,4],[4,4],[5,5],[5,10]] 我使用的代码是: fun pin2graph (pin,thatgraph,i,j,rows,cols,havepizza) = if (i<rows) andalso (j<cols-1) then ( pin2graph (pin,thatg

我试图创建一个列表列表,这意味着我的结果应该是

thatgraph = [[0,[1,2]],[1,[1,3],[1,4],[1,5]],[2,[3,4],[4,4],[5,5],[5,10]]
我使用的代码是:

 fun pin2graph (pin,thatgraph,i,j,rows,cols,havepizza) =

if (i<rows) andalso (j<cols-1) then   
        (
         pin2graph (pin,thatgraph::((i*cols+j),(getAdjacent (pin,i,j,rows,cols,havepizza))),i,j+1,rows,cols,havepizza)
        )
        else if (i<rows)  then
        (
        pin2graph (pin,thatgraph::((i*cols+j),(getAdjacent (pin,i,j,rows,cols,havepizza))),i+1,0,rows,cols,havepizza)
        )
        else thatgraph 
a实际上是一个实数,所以实数类型是(int*real)list

无论我尝试了什么,我总是得到一个操作数和运算符不匹配,最常见的是:

 operator domain: _ * _ list
 operand:         _ * (int * (int * 'Z) list)

任何提示都将不胜感激,因为没有任何想法

表明图表
的类型无效。e、 g.第一项
[0[1,2]]
包含
int
int列表作为元素。没有同时是
int
int-list
的类型(afaik),因此您不能拥有此不存在类型的列表。可以使用
int*(int-list list)
类型的元组,其中可以包括
(0,[[1,2]]
(1,[[1,3],[1,4],[1,5]]
)等值。当然,您可以创建此类元组的列表。在SML中,这是最接近您尝试做的事情。
 operator domain: _ * _ list
 operand:         _ * (int * (int * 'Z) list)