num b = foldl (sumProd b) 0 . map val str b = map dig . unfoldl (==0) (`divMod` b) [ (bin,unbin), (dec,undec), (hex,unhex) ] = map (\b -> (str b, num b)) [2,10,16]