feat(haskell): add likes kata

This commit is contained in:
Dmitriy Pleshevskiy 2021-10-29 23:32:33 +03:00
parent 83bb294b98
commit 864453f1eb
1 changed files with 8 additions and 0 deletions

8
haskell/5_likes.hs Normal file
View 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"