So this is my question: i wanna make a function that takes a list and and int, it then recursively moves through the list, and if it finds an element in the list equal to the int, then it should return the entire list with the element removed, and a boolean indicating wether something was removed. this is what i got so far:
fun foo ([], n) = ([],false)
| foo ((x::xs), n) = if x = n
then (xs,true)
else ([x] @ foo(xs,n),false);
my idea was to make the function cons the needed elements inside the tuple like this:
([x0] @ [x1] @ [x2] @ [xs], true)
so is there any way to make this function? keep in mind that it has to stop once it hits the element equal to n, but still retain the rest of the list, and be able to return a boolean. run time is key.