The following function counts how often I can divide one number by another:
divs n p = if (n `mod` p == 0) then 1 + divs (n `div` p) p else 0
Is there a shorter way to write divs?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
And more efficient too! Note that
quotRem, which behaves differently with negative values, is a tiny-tiny bit more efficient still.