Abstract

This paper is devoted to the synthesis of a functional version of the Knuth-MorrisPratt algorithm for pattern matching. This algorithm was first discussed by Knuth [6]; since then formal developments have been given by Dijkstra [4] and Dromey [5], among many others. The novel aspects of the present treatment are: (i) the result is expressed as a (very short) functional program; and (ii) the derivation makes use of the calculus of lists described by Bird [ 11. In order to make this paper as self-contained as possible, we shall indicate the concepts and notations of [l] used in our derivation as we go along. However, we do assume some familiarity with the basic ideas of functional programming. (For an introduction to functional programming, see Bird and Wadler [3].) The calculus of lists is based on the definition of lists as an algebraic structure (actually, a monoid) under the primitive operation of concatenation, denoted by the sign *. Thus

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call