このディレクトリの索引
#  I'm new to Prolog and my assignment requires us to implement a function as described below:
#  
#  Write a Prolog predicate zip(L1,L2,L3) that is true if the list L3 is obtained by zipping (i.e. shuffling", or interleaving") the elements of the lists L1 and L2. Update: the lists L1 and L2 can have different lengths. For instance, when you are done, you should get the following behavior:
#  
#  ?- zip([1,2],[a,b],[1,a,2,b]).
#  
#  true.
#  
#  ?- zip([1,2],[a,b],X).
#  
#  X = [1, 2, a, b] ;
#  
#  X = [1, 2, a, b] ;
#  
#  X = [1, a, 2, b] ;
#  
#  X = [1, a, b, 2] ;
#  
#  X = [a, 1, 2, b] ;
#  
#  X = [a, 1, b, 2] ;
#  
#  X = [a, b, 1, 2] ;
#  
#  X = [a, b, 1, 2] ;
#  
#  false.
#  
#  ?- zip([1,2],[a,b],[1,2,a,b]).
#  
#  true.
#  
#  ?- zip(X,[a,b],[1,a,2,b]).
#  
#  X = [1,2]
#  
#  true.
#  
#  ?- zip([1,2],X,[1,a,2,b]).
#  
#  X = [a,b]
#  
#  true.
#  I'm thinking of creating a list which contains elements from L1 and L2 and then compare the list with L3. But i'm not familiar with the syntax and loops in Prolog. Please help. Thanks!#
#  それぞれのならびの順序だけは維持して併合する
#

それぞれのならび順序だけは維持して併合([],[],[]).
それぞれのならび順序だけは維持して併合([U|X],Y,[U|Z]) :-
       それぞれのならび順序だけは維持して併合(X,Y,Z).
それぞれのならび順序だけは維持して併合(X,[U|Y],[U|Z]) :-
       それぞれのならび順序だけは維持して併合(X,Y,Z).