title: How to insert member list with menu driven prolog program?
body: <p>The Question is-</p>
  <p><strong>Write a menu driven PROLOG program to implement various operations on List such as- membership</strong></p>
  <p>My ans was -</p>
  <pre><code>main :-
      nl,
      writeln(&quot;&gt;   Enter a selection followed by a period.&quot;), nl,
      writeln(&quot;&gt;   1. Run a query&quot;), nl,
      writeln(&quot;&gt;   2. Exit&quot;), nl, nl,
      read(Choice),
      run_opt(Choice),main.
  
  run_opt(1) :-
      writeln(&quot;&gt;   Enter list&quot;), nl,
      read(L),
      member(X,[L]).
  
  
  run_opt(2) :- writeln(&quot;Goodbye&quot;), nl.
  
  run_opt(_) :- writeln(&quot;Invalid option&quot;), nl.
  
  member(X,[X|_]).
  member(X,[_|TAIL]):-
    member(X,TAIL).
  </code></pre>
  <p>This above program has problem and i can't insert member with menu driven insertion, like  i do this below without menu driven directly--</p>
  <pre><code>member(X,[X|_]).
  member(X,[_|TAIL]):-
  member(X,TAIL).
  </code></pre>
  <p>and the above program correctly executes when i put--</p>
  <pre><code>member(X,[1,2,3]).
  </code></pre>
  <p>and it displays members as-</p>
  <pre><code>X = 1
  X = 2
  X = 3
  </code></pre>
  <p>So, i need to do that thing with menu driven but i cant pass the list member in prolog.
  Thanks in advance.</p>