Question
Using SWI Prolog to do this question. Problem 4: Implement update, using Prolog's read, write, assert. % Update asks user for name and age,then %
Using SWI Prolog to do this question.
Problem 4: Implement update, using Prolog's read, write, assert.
% Update asks user for name and age,then
% asserts the answers in a structure: person(name(_), age(_)),
% then asks if the user wants to continue.
% (User must answer each question with a word
% or number ending in a period. No blanks
% allowed in answer. To simplify implementation
% of #4 and #5, user input must be all lowercase.)
% Test cases part I:
% ?- update.
% Name?: nancy.
% Age?: 22.
% Continue (y or n)?: y.
% Name?: steve.
% Age?: 100.
% Continue (y or n)?: x.
% Continue (y or n)?: n.
% true.
% Test cases part II:
% Ask Prolog to list all person structures
% to verify that update worked:
% ?- person(name(N), age(A)).
% N = nancy,
% A = 22;
% N= steve,
% A = 100;
% true.
% Type your Solution here:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started