Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-23 Thread Martin DeMello
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

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-21 Thread Henning Thielemann
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

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-21 Thread Gene A
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.

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-21 Thread Jules Bean
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

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-21 Thread Gene A
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

[Haskell-cafe] Re: Map list of functions over a single argument

2007-02-20 Thread apfelmus
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

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-20 Thread David House
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

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-20 Thread Nicolas Frisby
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