Boyer-Moore string search: Difference between revisions

J
(→‎{{header|Emacs Lisp}}: further cleanup)
(J)
Line 67:
 
<pre>33</pre>
 
=={{header|J}}==
{{trans|Emacs Lisp}}
<lang J>bmsearch=: {{
startPos=. 0
rightMap=. (i.#x) (3 u: x)} 256#_1
while. (#y) >: (#x)+startPos do.
skip=. 0
for_idx. i.-#x do.
if. (idx{x) ~: (startPos+idx) { y do.
skip=. 1 >. idx - rightMap {~ 3 u: y {~ startPos + idx
break.
end.
end.
if. skip do.
startPos=. startPos+skip
else.
startPos return.
end.
end.
_
}}</lang>
 
Example use:
<lang J> 'alfalfa' bmsearch 'On behalf of an alfredo calfskin malfunction we donate alfalfa.'
55</lang>
 
=={{header|Julia}}==
6,962

edits