mirror of
https://github.com/BinRoot/Haskell-Data-Analysis-Cookbook.git
synced 2024-11-25 10:03:47 +03:00
Combined two styles: pattern-matching vs if-then-else
Pattern matching (from book), if-then-else (from original code)
This commit is contained in:
parent
d6ab918c51
commit
8f9c4d2b23
@ -13,14 +13,28 @@ main = do
|
||||
phash3 <- imageHash "image3.jpg"
|
||||
putStrLn $ "image3: " ++ show phash3
|
||||
|
||||
if isJust phash1 && isJust phash2 then do
|
||||
putStr "hamming distance between image1 and image2: "
|
||||
print $ hammingDistance (fromJust phash1) (fromJust phash2)
|
||||
else
|
||||
print "Error, could not read images"
|
||||
|
||||
if isJust phash1 && isJust phash3 then do
|
||||
putStr "hamming distance between image1 and image3: "
|
||||
print $ hammingDistance (fromJust phash1) (fromJust phash3)
|
||||
else
|
||||
print "Error, could not read images"
|
||||
|
||||
{-
|
||||
case (phash1, phash2) of
|
||||
(Just h1, Just h2) -> do
|
||||
putStr "hammind distance: "
|
||||
putStr "hamming distance between image1 and image2: "
|
||||
print $ hammingDistance h1 h2
|
||||
_ -> putStrLn "Error, could not read images"
|
||||
|
||||
case (phash1, phash3) of
|
||||
(Just h1, Just h3) -> do
|
||||
putStr "hammind distance: "
|
||||
putStr "hamming distance between image1 and image3: "
|
||||
print $ hammingDistance h1 h3
|
||||
_ -> putStrLn "Error, could not read images"
|
||||
-}
|
||||
|
Loading…
Reference in New Issue
Block a user