Define a function dropOdds :: Int -> Int with the following behaviour. For any positive number m, dropOdds m is got by dropping all the odd digits in m. (If all the digits in the number are odd, the answer should be 0.)
Test cases:
dropOdds 0 = 0
dropOdds 8 = 8
dropOdds 1357 = 0
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (8)
Ok, I won't give you the answer directly since that'd be harmful to your learning. I'll ask 3 questions instead - try to answer them:-
You'll notice the quotes I put around the word "digits". I generally prefer using
Char
for "digits". But one may just as well useInt
. Whichever you use, your answers will depend on it.You can use recursion too :
Thanks man
Thankyou so much, I got it right!!!!!
...
I'm new to haskell. I want the solution for this so that I can understand the concepts
even I want this answer !!
With Recursion :