re: Daily Challenge #32 - Hide Phone Numbers VIEW POST


Today I'm folding the other way around. I've chosen not to validate the number format because I didn't want to spend the entire evening building a regex that matched all possible formats I can think of.

import Data.Char (isDigit)

hide_nums :: String -> String
hide_nums = snd . foldr kevin (0, "")
        kevin :: Char -> (Int, String) -> (Int, String)
        kevin char (x, result)
            | x >= 6       = (x, char:result)
            | isDigit char = (x + 1, 'x':result)
            | otherwise    = (x, char:result)

There no package for phone numbers?


Using a library kinda defeats the purpose of these exercises, don't you think?

But what's the fun in that?

Yes I'm just asking 😄 of there are one I'll use it, working with phone number is a bit hardwork since others country had different types phone code.

Code of Conduct Report abuse