Re: It seems that I found prolog in prolog



Joachim Schimpf wrote:
toplevel :-
write('?- '),
read_term(Query, [variable_names(NameVarPairs)]),
(
call(Query),
write(NameVarPairs),
get_char(Command),
Command \= (;)
->
write(yes)
;
write(no)
),
nl,
toplevel.

The key idea in your codes in the procedure call/1,
that makes me check the function of call/1.

If my auto-programming program writes codes
char by char , just as a person does , thus the
codes to be executed were in the form of string,
say,"write(hell_world)." Can the hello_world
program created by my program run via call/1?

Look :
------------------------------------------------------------------------------
Welcome to SWI-Prolog (Multi-threaded, Version 5.2.13)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- string_to_atrom(S,'write(hello_world).'),
| call(S).
Correct to: string_to_atom(S, write(hello_world).)? yes
ERROR: Type error: `callable' expected, found `"write(hello_world)."'
2 ?-
------------------------------------------------------------------------------------------
Anybody can see call/1 doesn't work , even for the simplest
program , eg Hello World.

There is obvious gap between the codes written by my program
and the "calable" . Is there any solution to this gap ?

.



Relevant Pages

  • :- at the beginning for assertional coding
    ... code he wroks out in the toplevel by using assertz/1 or ... If the programmer just save his codes, ... SWI-Prolog comes with ABSOLUTELY NO WARRANTY. ...
    (comp.lang.prolog)
  • GNU prolog is not so reliable as SWI-prolog
    ... The following codes is test in swi-prolog and can run smoothly. ... But the same codes' job just can't be finished in GNU prolog, ... the stack limitation. ...
    (comp.lang.prolog)
  • Re: Help - array formula nightmare!!!!
    ... with a heading like "Total" in C1 and this formula in C2: ... leaving a gap of a few rows, then put the first of your 7 subgroup ... subgroup codes in B and copy this down. ...
    (microsoft.public.excel.worksheet.functions)
  • Unget in SWI-prolog ?
    ... The codes that I gave for eof in the message ... just work find in GNU prolog, ... named unget_char in SWI-prolog. ...
    (comp.lang.prolog)
  • Re: recursive list question
    ... sbrown wrote: ... I gave some corrections to your codes, ... SWI-Prolog comes with ABSOLUTELY NO WARRANTY. ...
    (comp.lang.prolog)