aaaa

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import Data.Char

hash :: String -> Int
hash [] = -1
hash (x:xs) = ((ord x))

rabinKarp :: String -> String -> Int
rabinKarp [] _ = -1
rabinKarp mainString patternString
    let
     hashPattern = hash patternString
     hashMain = hash take length pattern mainString
    if hashPattern = hashMain
    then 1
    else rabinKarp (drop 1 mainString) patternString