Boyer-Moore string search: Difference between revisions

(added Raku programming solution)
Line 13:
=={{header|Emacs Lisp}}==
 
<langsyntaxhighlight lang=lisp>
;; Compile the pattern to a right most position map
(defun bm_compile_pattern (pattern)
;; "Compile the pattern to a right most position map"
(let ((patLen (length pattern))
(rightMap (make-vector 256 -1))
Line 24:
)
)
;;(print (bm_compile_pattern "abcdb"))
 
(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>
</lang>
 
outputs:
59

edits