[Haskell-beginners] Is there an idiom for this?
edwards.benj at gmail.com
Mon Nov 16 12:07:11 UTC 2015
You can be cute and use the applicative instance on functions: (&&) <$>
pred1 <*> pred2. I would recommend against such cuteness however and just
write out the arguments.
On Mon, 16 Nov 2015 at 11:54 emacstheviking <objitsu at gmail.com> wrote:
> I guess it depends on the final use cases... you could use currying to
> partially evaluate some stuff ready, locked and loaded as it were but the
> example you have given shows to distinct functions pres1 and pred2.
> I guess the short answer is "yes" but it depends on how you do it!
> On 16 November 2015 at 11:44, Mark Carter <alt.mcarter at gmail.com> wrote:
>> Suppose I want to use an argument twice, as for example in the expression:
>> (\x -> (pred1 x) and (pred2 x))
>> Is there a shorter way of doing this?
>> Beginners mailing list
>> Beginners at haskell.org
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners