Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to define the relation shift(L1,L2) so that L2 is L1 shifted rotationally by one element to the left

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 2795

Prolog program to define the relation shift(L1,L2) so that L2 is L1 shifted rotationally by one element to the left.

Code for Prolog program to define the relation shift(L1,L2) so that L2 is L1 shifted rotationally by one element to the left in Artificial Intelligence

domains
    x = integer
    l = integer*
    
predicates
    concatenate(l,l,l)
    shift_left(l,l)
    
clauses
    concatenate([],List,List).
    
    concatenate([X|List1],List2,[X|List3]) :-
        concatenate(List1,List2,List3).
        
    shift_left([X|Tail],List) :-
        concatenate(Tail,[X],List).

        
Output :

Goal: shift_left([1,2,3,4],List)
List=[2,3,4,1]
1 Solution
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to define the relation shift(L1,L2) so that L2 is L1 shifted rotationally by one element to the left is from India.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!