Boyer-Moore string search: Difference between revisions
→{{header|Emacs Lisp}}
(added Raku programming solution) |
|||
Line 13:
=={{header|Emacs Lisp}}==
<
;; Compile the pattern to a right most position map▼
(defun bm_compile_pattern (pattern)
(let ((patLen (length pattern))
(rightMap (make-vector 256 -1))
Line 24:
)
)
(defun bm_substring_search (pattern text)
Line 33 ⟶ 32:
(result nil)
(rightMap (bm_compile_pattern pattern)))
;; Continue this loop when no result and not exceed the text length
(while (and (not result) (<= (+ startPos patLen) txtLen))
Line 62 ⟶ 60:
(bm_substring_search pattern full_text)
)
</syntaxhighlight>
outputs:
|