Name the predicates that are used by Prolog for InputOutput

Name the predicates that are used by Prolog for Input/Output and file handling? Include examples of how they would look in a program.

Solution

Answer:-

Input / Output :

A stream can be opened and connected to a filename or file descriptor for input or output by calling the predicate open/3. open/3 will return a reference to a stream.

The stream may then be passed as an argument to various I/O predicates. The predicate close/1 is used for closing a stream. The predicate current_stream/3 is used for retrieving information about a stream, and for finding the currently existing streams.

Prolog syntax:

The Prolog consists of one or more predicates; each predicate consists of one or more clauses. A clause is a base clause if it is unconditionally true, that is, it has no \"if part.\'\'

Prolog execution :

Most Prolog clauses have both a declarative reading and a procedural reading. Whenever possible, the declarative reading is to be preferred.

Declarative reading: X is the mother of Y if X is a parent of Y and X is female.

Approximate procedural reading: To show that X is the mother of Y, first show that X is a parent of Y, then show that X is female.

Suppose we have the additional base clauses:

Example :

Name the predicates that are used by Prolog for Input/Output and file handling? Include examples of how they would look in a program.SolutionAnswer:- Input / Ou

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site