probability a b s =
prob a b 0 0 s
where
prob a b b_num total [] = (fromIntegral b_num) / (fromIntegral total)
prob a b b_num total (x:y:xs) | x == a && y == b = prob a b (b_num + 1) (total + 1) (y:xs)
prob a b b_num total (x:xs) | x == a = prob a b b_num (total + 1) xs
prob a b b_num total (x:xs) = prob a b b_num total xs
main = do
s <- readFile "D:\\dev\\test\\frequency\\forsyte_saga.txt"
putStrLn $ show (round $ probability 'F' 'o' s * 100) ++ "%"