[Haskell-cafe] Suggestions for improvement
Dominique Devriese
dominique.devriese at cs.kuleuven.be
Sun Oct 3 17:24:03 EDT 2010
Gregory,
2010/10/3 Gregory Crosswhite <gcross at phys.washington.edu>:
> On 10/3/10 1:45 PM, Dominique Devriese wrote:
>>
>> Additionally, you can't combine the functions (blowup . allButLast)
>> and lastToTheLength into a function that returns a pair like you seem
>> to attempt. You need a function like the following for that:
>>
>> comma :: (a -> b) -> (a -> c) -> a -> (b,c)
>> comma f g x = (f x, g x)
>>
>> Then you could say:
>>
>> blowup = (uncurry (++)) . comma (blowup . allButLast) lastToTheLength
>
> It is worth noting that such a function already exists in the standard
> libraries; it is the &&& operator in Control.Arrow:
>
> blowup = uncurry (++) . (blowup . allButLast &&& lastToTheLength)
Or you can write it as (liftA2 (,)) as I noted a few lines further in my mail ;)
Dominique
More information about the Haskell-Cafe
mailing list