Parameter Rule InputList As List Dim inList As List={"d","a","b","c","a","b","c","a","b","c","a","b","c","a","c"} Return inList End Rule Parameter Rule PatternList As List Dim patList As List={"a","b","c"} Return patList End Rule Rule PatternMatch As List Dim patternPositionList As List={} Dim lengthInputList As Number=length(InputList) Dim lengthPatternList As Number=length(PatternList) Dim i As Number=1 Dim j As Number=1 While i<=lengthInputList If j<=lengthPatternList And nth(i, InputList)=nth(j, PatternList) Then j=j+1 i=i+1 ElseIf j=1 i=i+1 ElseIf j<=lengthPatternList j=nth(j-1,FailurePosList)+1 Else 'pattern match patternPositionList=patternPositionList+{i-lengthPatternList} j=nth(lengthPatternList,FailurePosList)+1 End If End While If j>lengthPatternList Then 'pattern match patternPositionList=patternPositionList+{lengthInputList-lengthPatternList+1} End If Return patternPositionList End Rule Rule FailurePosList As List Dim failPosList As List Dim lengthPatternList As Number=length(PatternList) failPosList=failPosList+{0} Dim j As Number For j=2 To lengthPatternList Dim i As Any=nth(j-1,failPosList) While ((nth(j,PatternList)<>nth(i+1,PatternList)) And i>=1) i=nth(i-1,failPosList) End While If nth(j,PatternList)=nth(i+1,PatternList) Then failPosList=failPosList+{i+1} Else failPosList=failPosList+{0} End If Next Return failPosList End Rule