I have trouble understanding what your code is intended to do and I do not think it works as it stands.
- The comparison can not be correct.
- atom_to_term/3 sounds like it takes an atom as first argument, your code looks like it passes a list.
- I do not know what startsWith/3 does, but I assume it is similar to append/3 with different argument order. In particular I assume it can succeed more than once.
- I suspect that better_attribute3_in(f22,f22), better_attribute3_in(f12,f22), and better_attribute3_in(f22,f12) are all true. Is this intentional? If so, what is better_attribute3_in/2 supposed to mean?
(To get something that mimics the original code you could probably replace startsWith(A,B,C) with append(B,C,A) and replace atom_to_term(A,B,C) with name(A,B)).