🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #782

A String Match/Append Function

#782
From: Eric Iverson
Date: Mon, 09 Apr 1990 20:44
24 lines
1418 bytes
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
Technical Details
Message-ID: <EIVERSON.90Apr9144415@hades.nmsu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!opus!eiverson

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <EIVERSON.90Apr9144415@hades.nmsu.edu>
Date: 9 Apr 90 20:44:15 GMT
Sender: news@nmsu.edu
Distribution: comp
Organization: NMSU Computer Science
Lines: 24