Search:

Submit Article

# Program that defines a relation split(L,P,N) where list is divided into positive, negative numbers without using cut

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

## Code for Program that defines a relation split(L,P,N) where list is divided into positive, negative numbers without using cut in Artificial Intelligence

```domains
l = integer*

predicates
split(l,l,l)

clauses
split([],[],[]).

split([X|List] , Positive , [X|Negative]) :-
X < 0,
split(List,Positive,Negative).

split([X|List] , [X|Positive] , Negative) :-
X >= 0,
split(List,Positive,Negative).

Output :

Goal: split([-1,1,-2,2,-3,3],PosList,NegList)
PosList=[1,2,3], NegList=[-1,-2,-3]
1 Solution
```
Share:

 Milind Mishra author of Program that defines a relation split(L,P,N) where list is divided into positive, negative numbers without using cut is from India. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!