amit-singhs / test-elm

This is a test elm repository.
test-elm-git-master.amit-singhs.vercel.app
0 stars 0 forks source link

isPalindrome : List a -> Bool #7

Open renovatorruler opened 3 years ago

renovatorruler commented 3 years ago

Create a function called isPalindrome which will take a List a and return whether it is a palindrome or not (see example or ask me for clarification).

λ> isPalindrome [1,2,3]
False
λ> isPalindrome "madamimadam"
True
λ> isPalindrome [1,2,4,8,16,8,4,2,1]
True
amit-singhs commented 3 years ago

main = text(stringFromBool(isPalindrome ls))

isPalindrome : List String -> Bool isPalindrome xs = xs == listReverse xs

listReverse : List String -> List String listReverse xs = case xs of [] -> [] x:: tail -> (listReverse tail) ++ [x] stringFromBool : Bool -> String stringFromBool value = if value then "True"

else "False"

renovatorruler commented 3 years ago

Add code by encasing it like this btw

image