I have to implement rabin karps algorithm into Haskell, I think my code is right but it's not working for me
When I compile I get an "parse error on let" error.
Just wondering if anybody could look at the code and tell me what's wrong with it, I think it could be indentation but usually Haskell tells you.
Thanks for any help!
import Data.Char
hash :: String -> Int
hash [] = -1
hash (x:xs) = ((ord x))
rabinKarp :: String -> String -> Bool
rabinKarp [] _ = False
rabinKarp mainString patternString
let
hashPattern = hash patternString
hashMain = hash (take (length pattern) mainString)
if hashPattern == hashMain
then True
else rabinKarp (drop 1 mainString) patternString

New Topic/Question
Reply


MultiQuote




|