Prolog How can I construct a list of list into a single list by interleaving?
问题 How can I construct a list of a list into one single list with interleaving sublists? like recons([[1,2],[3,4]],X) will give X= [1,3,2,4]? I have been trying hours and my code always gave me very strange results or infinite loop, what I thinking was something like this: recons([[A|R],REST],List):- recons(R,REST), append(A,[R|REST],List). I know its completely wrong, but I don`t know how to fix this. 回答1: Instead of thinking about efficiency first, we can think about correctness first of all.