WL Ko wrote: > I get what you mean, I guess I probably should have made myself clearer: I > would prefer to print out the original problem along with the solution, so > that I can tell at once it is SEND + MORE, and not _519_521_523_525 + > _527_529_531_521. In that case I would need something that can take in > "[S,E,N,D]+[M,O,R,E]=[M,O,N,E,Y]", and print: > SEND > + MORE > MONEY You probably want something similar to the toplevel user interface. To do that, you indeed need a string: run_string(String) :- open(string(String), read, Stream), read_term(Stream, Goal, [variable_names(Vs)]), close(Stream), call(Goal), ( foreach(V,Vs) do writeln(V) ). The read_term/3 converts the string into a term, and also gives you a list with the mapping of variable names to variables. ?- run_string("cryptarith([[S,E,N,D]+[M,O,R,E]=[M,O,N,E,Y]],10)"). would then print: S = 9 E = 5 N = 6 D = 7 M = 1 O = 0 R = 8 Y = 2 (using example code http://eclipse-clp.org/examples/cryptarith.ecl) -- JoachimReceived on Thu Mar 11 2010 - 07:21:23 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET