How can i create a prdicate for doubling every second entry of a list and discarding the others using an accumulator?
e.g
?-double(['g',o,o,g,l,e],T).
T = [o,o,g,g,e,e]
If you use an accumulator, your predicate use 2 args for it, the current state of the accumulator and the final state of it.
Generally, if it's a list it's initialized with [].
The final state is unified when you have finished the work.
I can give you the beginning of the code :
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.