I need some help with three prolog predicates for checking and manipulating lists. I'm new to prolog and any help would be much appreciated.
The three predicates are:
double_up(+List1, -List2)is true whenList2has each element ofList1twice. The querydouble_up([a,b,c],X)should giveX=[a,a,b,b,c,c]. The order of the elements in the output list does not matter.pivot(+List1, +Pivot, -Smaller, -GreaterEq)is true whenSmalleris the list of numbers inList1smaller thanPivot, andGreaterEqis the list of numbers inList1bigger than or equal toPivot.fancy_replace(+List, +Takeout,+Putin, -NewList, -Count)is true whenNewListis the same list as the inputList, but where eachTakeoutelement in the list is replaced with thePutinelement. Count should be the number of Takeouts that got replaced. For example, the queryfancy_replace([9,10,1,9,2],9,0, X, C)should giveX = [0,10,1,0,2]andC = 2. The order of the elements in the output list does not matter.