Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define and test the Prolog predicates described below. Each of your predicates must have the same name and signature as the examples below . Your

Define and test the Prolog predicates described below. Each of your predicates must have the same name and signature as the examples below. Your predicates must behave properly on all instances of valid input types. Your submission should consist of a single source code text file that includes all facts, predicate definitions, and propositions.

You may find additional Prolog language help at the following links:

SWI-Prolog manual: http://www.swi-prolog.org/pldoc/refman/

SWI-Prolog documentation: http://www.swi-prolog.org/pldoc/index.html

Learn Prolog Now: http://www.learnprolognow.org/

2) List Product

Define a predicate list_prod/2 that takes a list of numbers as a first parameter and

determines the product of all of the list elements in the second parameter. Your

predicate should have the signature list_prod(List, Number). The product of an

empty list should be zero.

Examples:

?- list_prod([4,3], Product).

Product = 12.

?- list_prod([5,5,5], Product).

Product = 125.

?- list_prod([7,8,0,13], Product).

Product = 0.

?- list_prod([6,2,5,10], Product).

Product = 600.

?- list_prod([], Product).

Product = 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions