I'm trying to write function, that replace digits at some positions in number.
f 91521 [3,4] -> [91001,91111,91221,91331,91441,91551,91661,91771,91881,91991]
It's behavior like
91**1 -> ..., so I named it as a 'whitemask'.
Question 1: is "whitemask" a normal and adequately name for that function?
After that I've formulated that 'whitemask' function.
sublists :: (Eq a) => [a] -> [[a]] sublists list = [x | x <- subsequences list, x /= ] numbers :: [Int] numbers = take 10 [0..] numLength :: Integer -> Int numLength = length . show decreaseList :: Num a => [a] -> a -> [a] decreaseList = (\a b c -> map (a c) b) (flip (-)) listToNum :: [Int] -> Integer listToNum digits = toInteger $ foldl1 (\x y -> x*10 + y) digits numToList :: Integer -> [Int] numToList x = map digitToInt $ show x remove :: [Int] -> [Int] -> [[Int]] remove  x = [x] remove (x:xs) list = putted : remove (decreaseList xs x) unputted where [putted,unputted] = (\(x,y) -> [init x,y]) $ splitAt x list sew :: [[a]] -> a -> [a] sew list sewer = foldr1 (\x y -> x ++ [sewer] ++ y) list whitemask :: Integer -> [Int] -> [Integer] whitemask num places = filter (\x -> numLength x == numLength num ) $ map (listToNum . sew (remove places (numToList num))) numbers
But in context of all problem where that function might be used I figured out, that I need only fix-length answers. For examples, it works like
> whitemask 75148 [1,3,4] [15118,25228,35338,45448,55558,65668,75778,85888,95998]
and answer isn't contain '5008' element.
Question 2: is that fix-length filtering 'whitemask' function's business? Or it would be better to return all possible variants and filtering them if it really needed?
When I've started to use that function in complicated iterates ways I figured out that it's might do some unnecessary and superfluous calculations.
Question 3: how can I refactor 'whitemask' function with less-usage folds maps and recursions?
Any cosmetics and style advices are appreciated.
ps: did I select the right place to asking for? (question could be migrated to SO actually)
I figured out that
sew can be written much easier.
sew list sewer = concat $ intersperse [sewer] list