我在sml中写这个函数
fun removeNodeswithNoIncoming((x:int,y)::xs,element:int) =
if x=element then
removeNodeswithNoIncoming (xs , element)
else
(x,y) :: removeNodeswithNoIncoming (xs , element)
| removeNodeswithNoIncoming(nil,element) = nil;
该函数采用元组[(0,0),(0,1)(1,2)]和另一个元素0的列表 如果元组的第一个元素与第二个参数相同,则将其从列表中删除 上述列表的o / p应为[(1,2)]
不幸的是,代码不能用于上述输入。虽然还有其他可用的输入
- removeNodeswithNoIncomingEdge([(0,1),(0,2),(1,2)],0);
stdIn:30.1-30.30 Error: unbound variable or constructor: removeNodeswithNoIncomi
ngEdge
- removeNodeswithNoIncomingEdge([(0,1),(0,2),(1,2),(1,4)],0);
stdIn:1.2-1.31 Error: unbound variable or constructor: removeNodeswithNoIncoming
Edge
答案 0 :(得分:1)
您的错误消息是指removeNodeswithNoIncomingEdge
,但您的功能定义是removeNodeswithNoIncoming
。