DEV Community

Discussion on: Please help me with this haskell program.

Collapse
 
totally_chase profile image
Phantz

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:-

  • How can you turn a number into a list of "digits".
  • How can you check if a "digit" is odd?
  • How do you "drop" certain elements of a list that match a criteria? (hint: filter)

You'll notice the quotes I put around the word "digits". I generally prefer using Char for "digits". But one may just as well use Int. Whichever you use, your answers will depend on it.

Collapse
 
benjioe profile image
Benjioe • Edited

You can use recursion too :

  • How can you check if a "digit" is odd?
  • How can you apply a function only on first digit?
  • How can you apply that function on each other digits?
Collapse
 
shashwatseth profile image
Shashwat Seth

Thanks man

Collapse
 
shashwatseth profile image
Shashwat Seth

Thankyou so much, I got it right!!!!!