diff options
| author | Edoardo La Greca | 2025-09-15 18:55:46 +0200 |
|---|---|---|
| committer | Edoardo La Greca | 2025-09-15 18:56:27 +0200 |
| commit | be5fe5353ab0554a999200d5cab593fdb8a2b5c4 (patch) | |
| tree | 1bda838ca140b27373905db3d84b5db48d223dba | |
| parent | 52e7f3d06b22959212c114f557a392d986d65fc9 (diff) | |
improve score in third exercise
| -rw-r--r-- | lec07/Scrabble.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lec07/Scrabble.hs b/lec07/Scrabble.hs index 2c3b1f9..b0b34f9 100644 --- a/lec07/Scrabble.hs +++ b/lec07/Scrabble.hs @@ -1,6 +1,6 @@ module Scrabble where import Data.Char -import Data.List ((!?)) +import Data.List -- Exercise 3 @@ -15,7 +15,7 @@ instance Monoid Score where mempty = Score 0 score :: Char -> Score -score c = Score $ fromMaybe 0 $ scores !? (fromEnum (toUpper c) - fromEnum 'A') +score c = Score $ fromMaybe 0 $ (!?) scores $ fromEnum (toUpper c) - fromEnum 'A' where scores = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10] :: [Int] scoreString :: String -> Score |