Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Programming languages > Need Help urgently
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 12th September 03:40
terry_513
programming
Mombu User
 
Join Date: Sep 2008
Location: Mumbai, India
Posts: 0
terry_513 is on a distinguished road
Question Need Help urgently



Hello,

I am very new to Prolog & need your assistance badly and urgently. I got to write a program where the provided phrase will be converted into decoded text. Like for char A, the text would be 'X', for B, 'XX', etc.

Truly saying I don't know where to start & how to start. I provided all decoded values in the following form :
code(A, X) :- true.
code(B, XX).
code(C, XXY).
code(D, XY).
code(E, Y).
code(F, YX).
code(G, YXX).
code(H, XXZ).
code(I, XZ).
code(J, Z).
code(K, ZX).
code(L, ZXX).
code(M, ZXXY).
code(N, ZXY).
code(O, ZY).
code(P, ZYX).
code(Q, ZYXX).
code(R, XXZZ).
code(S, XZZ).
code(T, ZZ).
code(U, ZZX).
code(V, ZZXX).
code(W, ZZXXY).
code(X, ZZXY).
code(Y, ZZY).
code(Z, ZZYX).

Now how do I proceed. Suppose I make a atom _phrase = 'I am doing this'.
Now, I need to read each single char, get the respective code from the codes and concat with a new string/atom.
I am not getting how to do with that for loop (each char in atom). For getting respetive code, I guess:
code(Z, _value) // will the value of Z be stored in the _value variable


Please help me out. The logic is very simple and quiet small, but being very new for the language I am not able to make it or I guess start it.
Any help is highly appreciated. Iam really in a hurry, its urgent.

Thanks
terry_513 is offline   Reply With Quote


 


Reply


Thread Tools
Display Modes




666