feat(haskell): add likes kata
This commit is contained in:
parent
83bb294b98
commit
864453f1eb
1 changed files with 8 additions and 0 deletions
8
haskell/5_likes.hs
Normal file
8
haskell/5_likes.hs
Normal file
|
@ -0,0 +1,8 @@
|
|||
module Likes where
|
||||
|
||||
likes :: [String] -> String
|
||||
likes [] = "no one likes this"
|
||||
likes [a] = a ++ " likes this"
|
||||
likes [a, b] = a ++ " and " ++ b ++ " like this"
|
||||
likes [a, b, c] = a ++ ", " ++ b ++ " and " ++ c ++ " like this"
|
||||
likes (a:b:rest) = a ++ ", " ++ b ++ " and " ++ show (length rest) ++ " others like this"
|
Loading…
Reference in a new issue