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.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.