Advertisement
ulysses4ever

replaceByCode

Nov 20th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.Digits
  2. import Data.List
  3.  
  4. intToBin = map (`mod` 2) . takeWhile (>0) . iterate (`div` 2)
  5.  
  6. replaceByCode l code d = let
  7.     cs = intToBin code
  8.     targetDs = map fst $ filter ((==1) . snd) $ zip l cs
  9.     in
  10.         if length (group targetDs) == 1
  11.         then unDigits 10 $ zipWith (\(dOld, c) -> if c == 1 then 5 else dOld) l cs
  12.         else 0
  13.  
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement