prefix([],x) = true prefix(h::t,[]) = false prefix(a::u,b::v) = (a == b) and prefix(u,v)
An alternative is as follows. It assumes that the equations are tried in the order written, and that the first one whose pattern matches is chosen.
prefix(a::u, a::v) = prefix(u, v) prefix([], y) = true prefix(x, y) = false