Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.60 KB | None | 0 0
  1. (** Verifica se uma string é substring de outra.
  2. @param stringToBeFound Cadeia de caracteres pelo qual procuramos
  3. @param stringToBeChecked Cadeia de caracteres aonde procurar *)
  4. and checkIfStringIsContainedIn stringToBeFound stringToBeChecked initialPos =
  5.     if initialPos < String.length stringToBeChecked &&
  6.        length stringToBeChecked <= length stringToBeFound then
  7.         ( let subString = (String.sub stringToBeChecked initialPos (String.length stringToBeFound)) in
  8.               if stringToBeFound = subString then true
  9.               else checkIfStringIsContainedIn stringToBeFound subString (initialPos+1) )
  10.     else false
Add Comment
Please, Sign In to add comment