CaptainSafety
Programmer
Hello. I am new to prolog. I am trying switch letters in a string to the opposite letter in the alphabet. This is my program, I can swap one letter but not change an entire String. Help me please.
letter(a, z).
letter(b, y).
letter(c, x).
letter(d, w).
letter(e, v).
letter(f, u).
letter(g, t).
letter(h, s).
letter(i, r).
letter(j, q).
letter(k, p).
letter(l, o).
letter(m, n).
letter(n, m).
letter(o, l).
letter(p, k).
letter(q, j).
letter(r, i).
letter(s, h).
letter(t, g).
letter(u, f).
letter(v, e).
letter(w, d).
letter(x, c).
letter(y, b).
letter(z, a).
swap(X) :- letter(Y, X), write(Y).
letter(a, z).
letter(b, y).
letter(c, x).
letter(d, w).
letter(e, v).
letter(f, u).
letter(g, t).
letter(h, s).
letter(i, r).
letter(j, q).
letter(k, p).
letter(l, o).
letter(m, n).
letter(n, m).
letter(o, l).
letter(p, k).
letter(q, j).
letter(r, i).
letter(s, h).
letter(t, g).
letter(u, f).
letter(v, e).
letter(w, d).
letter(x, c).
letter(y, b).
letter(z, a).
swap(X) :- letter(Y, X), write(Y).