Colin Adams wrote:
2009/1/13 Andrew Coppin andrewcop...@btinternet.com:
One of the wonderful things about Haskell is that almost any time anybody
posts code, at least one person will think up an alternative but equivilent
way of achieving the same goal - sometimes by radically different
Hi
convert b 0 = []
convert b n = n `mod` b : convert b (n `div` b)
convert b = unfoldr (\n - if n 0 then Just (n `mod` b, n `div` b) else
Nothing)
To my untrained eyes the second looks more complex... It can't be
implemented in the HLint list recursion functions I've got at the
moment
Andrew Coppin wrote:
Does it suggest unfoldr too?
I think Neil's idea to have this customizable is a good one.
It's often a matter of taste.
I would rarely want to use unfoldr, and I wouldn't want HList
to bother me about it. Instead, I prefer to use iterate for both
of Andrew's examples:
Robin Green wrote:
On Mon, 12 Jan 2009 21:04:35 +0100 (CET)
Henning Thielemann lemm...@henning-thielemann.de wrote:
On Mon, 12 Jan 2009, Andrew Coppin wrote:
convert b = unfoldr (\n - if n 0 then Just (n `mod` b, n `div`
b) else Nothing)
I have the nice function 'toMaybe'
2009/1/13 Andrew Coppin andrewcop...@btinternet.com:
One of the wonderful things about Haskell is that almost any time anybody
posts code, at least one person will think up an alternative but equivilent
way of achieving the same goal - sometimes by radically different steps.
Maybe we should
Colin Adams wrote:
2009/1/13 Andrew Coppin andrewcop...@btinternet.com:
One of the wonderful things about Haskell is that almost any time anybody
posts code, at least one person will think up an alternative but equivilent
way of achieving the same goal - sometimes by radically different
On Mon, 2009-01-12 at 21:48 +, Robin Green wrote:
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 (n0) (n `mod` b, n `div` b))
I would use the more general
Colin Adams colinpaulad...@googlemail.com writes:
One of the wonderful things about Haskell is that almost any time anybody
posts code, at least one person will think up an alternative but equivilent
way of achieving the same goal - sometimes by radically different steps.
Maybe we should
Neil Mitchell wrote:
Hi Andrew,
HLint will automatically detect if you should have used a map, a foldr
or a foldl and suggest how to change your code. In the GHC, darcs and
Hoogle code bases there are no obvious map-like functions, which is a
good sign :-)
...What an intriguing
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
On Mon, 12 Jan 2009 21:04:35 +0100 (CET)
Henning Thielemann lemm...@henning-thielemann.de wrote:
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
11 matches
Mail list logo