0

この関数を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 を取り、タプルの最初の要素が 2 番目のパラメーターと同じ場合、リストから削除します 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
4

1 に答える 1

1

エラー メッセージは を参照してremoveNodeswithNoIncomingEdgeいますが、関数定義はremoveNodeswithNoIncomingです。

于 2012-09-24T21:36:54.840 に答える