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
Get step-by-step solutions from verified subject matter experts
