On Mon, 12 Jan 2009, Andrew Coppin wrote:
Off the top of my head, try this: convert b 0 = [] convert b n = n `mod` b : convert b (n `div` b) (Takes a number and yields the radix-B representation of it. Backwards.) convert b = unfoldr (\n -> if n > 0 then Just (n `mod` b, n `div` b) else Nothing)
I have the nice function 'toMaybe' which simplifies this to: unfoldr (\n -> toMaybe (n>0) (n `mod` b, n `div` b)) Maybe HLint can also suggest non-base functions? ;-) http://hackage.haskell.org/packages/archive/utility-ht/0.0.2/doc/html/Data-Maybe-HT.html _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
