This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Knuth-Morris-Pratt demonstration | |
# Kyle Gorman <kgorman@ling.upenn.edu> | |
# | |
# A naive Python implementation of a function that returns the (first) index of | |
# a sequence in a supersequence is the following: | |
def subsequence(needle, haystack): | |
""" | |
Naive subsequence indexer; None if not found |
NewerOlder