Question: Write the program smp that when given the list [12, 2, 2, w, 3, 3, s, s, s], it returns the list [1*12, 2 *

Write the program smp that when given the list [12, 2, 2, w, 3, 3, s, s, s], it returns the list [1*12, 2 * 2, 1* w, 2 * 3, 3 * s].

This relation simply represents the sequential runs of N identical terms T as the term N*T.

Implement two versions of your solution, one using the cut and one without it.

For example,

? - smp([ 12, 2, 2, w, 3, 3, s, s, s ],L).

L = [1*12, 2*2, 1*w, 2*3, 3*s]

prolog programming

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!