I have created a function in SML that traverses the starting elements of a list and if first,second,third.. element are the same deletes these elements and updates a variable's value.What i have written:
let
val min=7
in
fun seen2 (set:int list) =
if hd set=hd(tl set) then
min=min-1
seen2(tl set)
else
tl set
end
The output of this function is meant to be a list with the elements i mentioned deleted.For example if it gets this list as input->[1,1,1,1,2,3,4] and min is set as 7 from before i excpect it to give [2,3,4] as a result and min to updated to 4.The min variable should be stored because this function will probably be called again and min may get further updated.This code gives me syntax errors.At the end the final min must be printed so i think this has to be something liek a global value(?).How could i accomplish this?