
I think i saw a relevant stackoverflow question before, but I can't find
it. Anyways, the answer said something like:
liftA2 (&&) pred1 pred2
which has the type a -> Bool, as desired. The reader applicative gives your
input to both predicates and (&&) is applied to their results. Hope I
remembered this correctly.
On Nov 16, 2015 4:01 AM,
Send Beginners mailing list submissions to beginners@haskell.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-request@haskell.org
You can reach the person managing the list at beginners-owner@haskell.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..."
Today's Topics:
1. Is there an idiom for this? (Mark Carter) 2. Re: Is there an idiom for this? (emacstheviking)
----------------------------------------------------------------------
Message: 1 Date: Mon, 16 Nov 2015 11:44:35 +0000 From: Mark Carter
To: beginners@haskell.org Subject: [Haskell-beginners] Is there an idiom for this? Message-ID: <5649C1A3.1010901@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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?
------------------------------
Message: 2 Date: Mon, 16 Nov 2015 11:53:28 +0000 From: emacstheviking
To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell Subject: Re: [Haskell-beginners] Is there an idiom for this? Message-ID: Content-Type: text/plain; charset="utf-8" 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!
:) Sean
On 16 November 2015 at 11:44, Mark Carter
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners