let rec r=function|'!'::t->(1-r t)|'0'::[]->0|_->1
let rec string_of_list = function
| h::t -> System.String([|h|]) + string_of_list t
let test (input,expected) =
if result = expected then
printfn "%s = %d" (string_of_list input) result
printfn "Error at %s" (string_of_list input)
(['!';'!';'!';'0';'!';'!';'!';'!'], 0)
(['!';'!';'!';'1';'!';'!';'!';'!'], 0)