質問

I have an assert query that is something like:

:- dynamic a/1,b/1.

dump:- listing(a),listing(b).

main:-retractall(a(X)),assert(a(1):-write('aa')),
      retractall(b(X)),assert(b(1):-write('bb')).

I want the user to type a(1) or b(1), the program to display aa or bb respectively (so far so good) and then to call another procedure,depending on what the user has typed.

For instance, if he typed a(1), I want a procedure called pro_a to run, and respectively if he types b(1), a procedure pro_b will run

These procedures will be:

  pro_a:- retractall(a(X)),retractall(b(X)),write('you chose a'),
          assert(a(1):-write('aa1')).

  pro_b:- retractall(a(X)),retractall(b(X)),write('you chose b'),
          assert(b(1):-write('bb1')).

and so on.

What I tried is something like:

assert(a(1):-write('aa'),pro_a).

But that doesn't work. Is assert supposed to have only one command? (I'm not sure how to explain this).

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top