Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

any other implementations???

Status
Not open for further replies.

winnie3

Programmer
Joined
Oct 12, 2002
Messages
1
Location
NZ
Hi, I would be grateful if anyone can give me any idea of solving this prolog problem :)

Here it is...

I would like to get the first two elements from a list and to check whether there's any repeated occurances in the list by comparing the two first elements and the rest of the list:

checking first two "a,b" in [a,b,c,d,e,d,a,b,e,a,a,b]

Moreover, i would like to have another list returned like this:

[[a,b],c,d,e,d,[a,b],e,a,[a,b]] which replaces all the occurances of "a,b" with [a,b]

I've tried using the built-in functions such as 'bagof' and 'member', however, they didn't make it work since they can only search a single element from a list. Can anyone think of any better implementations? Thanks.......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top