package fuzzy_match

  1. Overview
  2. Docs
Libraries for fuzzy string matching

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=33c0511fd8feba43b7904c6a9a0b9ccae77f9ba79e58a8918ef9f8f4d6e2e887

doc/src/fuzzy_match.match/fuzzy_match.ml.html

Source file fuzzy_match.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
open! Core

let is_match ~char_equal ~pattern text =
  let pattern_length = String.length pattern in
  let text_length = String.length text in
  let rec helper pattern_index text_index =
    if pattern_index = pattern_length
    then true
    else if text_index = text_length
    then false
    else (
      let pattern_char = String.unsafe_get pattern pattern_index in
      let text_char = String.unsafe_get text text_index in
      if char_equal pattern_char text_char
      then helper (pattern_index + 1) (text_index + 1)
      else helper pattern_index (text_index + 1))
  in
  helper 0 0
;;
OCaml

Innovation. Community. Security.