Runtime error in sml function

Posted by Rpant on Stack Overflow See other posts from Stack Overflow or by Rpant
Published on 2012-09-22T00:40:51Z Indexed on 2012/09/24 21:37 UTC
Read the original article Hit count: 204

Filed under:

I am writing this function in 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;

the function takes list of tuples [(0,0),(0,1)(1,2)] and another element 0 if first element of the tuples is same as second parameter , it removes it from the list The o/p for the above list should be [(1,2)]

Unfortunately , the code is not working for the above input. Though there are other inputs for which it works

- 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

© Stack Overflow or respective owner

Related posts about smlnj