Colin Adams wrote:
2009/1/13 Andrew Coppin :
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 have a
"Colin Adams" 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 have a name for this ef
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 (n>0) (n `mod` b, n `div` b))
>
> I would use the
Colin Adams wrote:
> 2009/1/13 Andrew Coppin :
>
>> 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 sh
2009/1/13 Andrew Coppin :
> 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 have a name for this ef
Robin Green wrote:
On Mon, 12 Jan 2009 21:04:35 +0100 (CET)
Henning Thielemann 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' which simplifies this to:
u
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:
>
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
On Mon, 12 Jan 2009 21:04:35 +0100 (CET)
Henning Thielemann 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 representation of
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
Not
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 idea
11 matches
Mail list logo