assaad
asked on
prolog splitting a list into 3 other lists and each have different type like + and -
Hi, i am trying to split a list into 3 lists: the first one consists of only positive numbers and the second one of negative numbers and the third one of atoms only for example:
?- partition([5,1,anything,-2 ,-3,10], L1, L2, L3).
L1= [5,1,10]
L2=[-2,-3]
L3=[anything]
any ideas????
?- partition([5,1,anything,-2
L1= [5,1,10]
L2=[-2,-3]
L3=[anything]
any ideas????
ASKER
this is prolog language.
?- partition([5,1,anything,-2 ,-3,10], L1, L2, L3). --> this is the question that the user should ask
the program should give him the following answer:
L1= [5,1,10]
L2=[-2,-3]
L3=[anything]
another example:
?- partition([5,1,anything,-2 ,whatever, 10], L1, L2, L3).
L1= [5,1,10]
L2=[-2]
L3=[anything,whatever]
by the way nothing should be stored in a file. it's only a simple interaction with the user.
the user will give the words including positive and negative numbers and we have to differenciate between them and put them in lists L1, L2, L3
?- partition([5,1,anything,-2
the program should give him the following answer:
L1= [5,1,10]
L2=[-2,-3]
L3=[anything]
another example:
?- partition([5,1,anything,-2
L1= [5,1,10]
L2=[-2]
L3=[anything,whatever]
by the way nothing should be stored in a file. it's only a simple interaction with the user.
the user will give the words including positive and negative numbers and we have to differenciate between them and put them in lists L1, L2, L3
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
did you try this to see if it's working?
What language are you using? Where is this data stored? In a file??
>> IM