On 2/22/07, Gene A [EMAIL PROTECTED] wrote:
The functions as I originally defined them are probably
easier for someone new to Haskell to understand what was going on than the
rather stark ($ a) in the final factoring of the function... Though the
final resulting function is far the cleaner for
On Tue, 20 Feb 2007 [EMAIL PROTECTED] wrote:
Paul Moore wrote:
I'm after a function, sort of equivalent to map, but rather than
mapping a function over a list of arguments, I want to map a list of
functions over the same argument. The signature would be [a - b] - a
- [b], but hoogle
On 2/21/07, Henning Thielemann [EMAIL PROTECTED] wrote:
On Tue, 20 Feb 2007 [EMAIL PROTECTED] wrote:
Paul Moore wrote:
I'm after a function, sort of equivalent to map, but rather than
mapping a function over a list of arguments, I want to map a list of
functions over the same argument.
Gene A wrote:
Well this is not very sexy, no monads or anything, but I kinda believe
in Keep It Simple:
Prelude let revApply a f = f a
Prelude let rMap a fs = map (revApply a) fs
Prelude rMap 2 [(*4),(^2),(+12),(**0.5)]
[8.0,4.0,14.0,1.4142135623730951]
Note that revApply here is
On 2/21/07, Jules Bean [EMAIL PROTECTED] wrote:
Gene A wrote:
Prelude let revApply a f = f a
Prelude let rMap a fs = map (revApply a) fs
Prelude rMap 2 [(*4),(^2),(+12),(**0.5)]
[8.0,4.0,14.0,1.4142135623730951]
Note that revApply here is precisely flip ($).
And ($a) is the same as flip
Paul Moore wrote:
I'm after a function, sort of equivalent to map, but rather than
mapping a function over a list of arguments, I want to map a list of
functions over the same argument. The signature would be [a - b] - a
- [b], but hoogle didn't come up with anything.
It seems like an
On 20/02/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
It's also known as
sequence :: Monad m = [m b] - m [b]
with m = (-) a
Don't forget to import Control.Monad.Instances for this to work.
--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe
Here comes an overwhelming post (so stop here if you're not interested
in applicative functors), but apfelmus stepped in this direction. The
funny part is that, modulo dictionary passing (which might be compiled
away), all 6 functions below do the Exact Same Thing because of
newtype erasure