Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!opus!eiverson From: eiverson@nmsu.edu (Eric Iverson) Newsgroups: comp.lang.prolog Subject: A String Match/Append Function Message-ID: Date: 9 Apr 90 20:44:15 GMT Sender: news@nmsu.edu Distribution: comp Organization: NMSU Computer Science Lines: 24 Here's a little puzzler for you. Write a program that handles the following input: gen([a,b,c,d,e,f],[b,c],[d,e],[b,c,d,e]). gen([a,b,c,d,e],[a,b],[c,d],[a,b,c,d]). gen([a,b,c,d,e],[b,c],[d,e],[b,c,d,e]). gen([a,b,c,d],[a,b],[c,d],[a,b,c,d]). gen([b,c,d,e],[a,b,c],[d,e],[a,b,c,d,e]). gen([a,b,c,d],[a,b],[c,d,e],[a,b,c,d,e]). gen([b,c,d,e],[a,b,c],[d,e,f],[a,b,c,d,e,f]). Essentially, given gen(A,B,C,D), make sure that there is a sublist of A such that the first part can be the tail of B, and the second part can be the head of C. At the same time, append B and C to form D. Can this be done in one traversal of the strings? -- ------------------------------------------------------------------------ Another Gruntpig production, in association with the Rat Lab Steamworks. Eric Iverson, president. Eric IVerson, emperor. ERiC IVerSoN, DeMIgOd!!! eiverson@nmsu.edu "I want to kill everyone here with a cute Computing Research Lab colorful Hydrogen Bomb!!" New Mexico State University -Zippy the Pinhead