From 864453f1ebe50ee54560cb6078f703d0aa96e0ee Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 29 Oct 2021 23:32:33 +0300 Subject: [PATCH] feat(haskell): add likes kata --- haskell/5_likes.hs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 haskell/5_likes.hs diff --git a/haskell/5_likes.hs b/haskell/5_likes.hs new file mode 100644 index 0000000..698f8bf --- /dev/null +++ b/haskell/5_likes.hs @@ -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" \ No newline at end of file