Home > database >  I need some ideea with a program in prolog with list
I need some ideea with a program in prolog with list

Time:02-22

The condition : Write the predicate joining two symbolic lists in the following way: the element 1 of the first list, the 1st element of the second list, the 2nd element of the first list, the 2nd element of the second list, etc. if the items of one of the lists have run out (this list is shorter list), in the resulting list is inserted the symbolic constant "null" until it will be go through the other list.

CodePudding user response:

Do you know how to rewrite a list changing its elements ? Do the same, but keep an eye on both input lists emptiness condition. Beware to commit (with a cut) when the task is completed.

Or, simpler, use append/3 when (at least) one of the two input lists is empty.

  • Related