このディレクトリの索引
#  Write a Prolog function mergealt(X,Y,Z), that makes the list Z a merger of alternate elements from the lists X and Y. and the input and out put will like below:
#  
#  ?- mergealt([1,2,3,4],[6,7,8],Z).
#  Z = [1, 7, 3] .
#  ?- mergealt([1,2,3,4],[6,7,8,9],Z).
#  Z = [1, 7, 3, 9] .
#  ?- mergealt([1,2,3,4],[6,7,8,9,10],Z).
#  Z = [1, 7, 3, 9] .
#  i m not really know recursion, so if someone can help me! thanks a lot if someone can help me.
#  

mergealt([],_,[]) :- !.
mergealt([A],[],[A]) :- !.
mergealt([A],[_],[A]) :- !.
mergealt([A],[_,B|_],[A,B]) :- !.
mergealt([A,_|R1],[_,B|R2],[A,B|R3]) :-
        mergealt(R1,R2,R3).