Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- delete :: Char -> [Char] -> [Char]
- delete a as = [ x | x <- as, x /= a]
- convertToInt n
- | n == 'X' = 10
- | otherwise = read [n] :: Integer
- isbnToList n = do
- let simplify = delete '-' n
- return [convertToInt a | a <- simplify ]
- BUT!!!!
- *Main> isbnToList "3-598-21508-8"
- [3,5,9,8,2,1,5,0,8,8]
- *Main> zipWith (*) [10,9,8,7,6,5,4,3,2,1] [3,5,9,8,2,1,5,0,8,8]
- [30,45,72,56,12,5,20,0,16,8]
- *Main> zipWith (*) [10,9,8,7,6,5,4,3,2,1] $ isbnToList "3-598-21508-8"
- <interactive>:140:9: error:
- • No instance for (Num [Integer]) arising from a use of ‘*’
- • In the first argument of ‘zipWith’, namely ‘(*)’
- In the expression: zipWith (*) [10, 9, 8, 7, ....]
- In the expression:
- zipWith (*) [10, 9, 8, 7, ....] $ isbnToList "3-598-21508-8"
Advertisement
Add Comment
Please, Sign In to add comment