Question: Programming language : Prolog Not allowed to use pre-defined predicates! Code a predicate shuffle/3 that shffles the two given lists into a third, i.e., interleaves

Programming language : Prolog

Not allowed to use pre-defined predicates!

Programming language : Prolog Not allowed to use pre-defined predicates! Code a

Code a predicate shuffle/3 that shffles the two given lists into a third, i.e., interleaves them in some way: the resulting list contains all elements of both given lists and only those, in their order of appearance in the given lists, but interleaved arbitrarily. The predicate must be able to accept and generate all valid outcomes of shuffling 2- shuffle([1,2,3,4], [a,b,c], [1 ,a , b ,2 , 3 , c ,4] ). true ?- shuffle([1], [a,b],Zs). false (The order in which answers are generated is not important.) Code a predicate shuffle/3 that shffles the two given lists into a third, i.e., interleaves them in some way: the resulting list contains all elements of both given lists and only those, in their order of appearance in the given lists, but interleaved arbitrarily. The predicate must be able to accept and generate all valid outcomes of shuffling 2- shuffle([1,2,3,4], [a,b,c], [1 ,a , b ,2 , 3 , c ,4] ). true ?- shuffle([1], [a,b],Zs). false (The order in which answers are generated is not important.)

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!