<p dir="ltr">I think i saw a relevant stackoverflow question before, but I can't find it. Anyways, the answer said something like:</p>
<p dir="ltr">liftA2 (&&) pred1 pred2</p>
<p dir="ltr">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.</p>
<div class="gmail_quote">On Nov 16, 2015 4:01 AM, <<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
<a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Beginners digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Is there an idiom for this? (Mark Carter)<br>
2. Re: Is there an idiom for this? (emacstheviking)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 16 Nov 2015 11:44:35 +0000<br>
From: Mark Carter <<a href="mailto:alt.mcarter@gmail.com">alt.mcarter@gmail.com</a>><br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Subject: [Haskell-beginners] Is there an idiom for this?<br>
Message-ID: <<a href="mailto:5649C1A3.1010901@gmail.com">5649C1A3.1010901@gmail.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
Suppose I want to use an argument twice, as for example in the expression:<br>
(\x -> (pred1 x) and (pred2 x))<br>
<br>
Is there a shorter way of doing this?<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Mon, 16 Nov 2015 11:53:28 +0000<br>
From: emacstheviking <<a href="mailto:objitsu@gmail.com">objitsu@gmail.com</a>><br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>><br>
Subject: Re: [Haskell-beginners] Is there an idiom for this?<br>
Message-ID:<br>
<CAEiEuULHWhechDwUF417Rnr55RDrEVUFVOgiQ6=<a href="mailto:5-8jux3pXyg@mail.gmail.com">5-8jux3pXyg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
I guess it depends on the final use cases... you could use currying to<br>
partially evaluate some stuff ready, locked and loaded as it were but the<br>
example you have given shows to distinct functions pres1 and pred2.<br>
<br>
I guess the short answer is "yes" but it depends on how you do it!<br>
<br>
:)<br>
Sean<br>
<br>
<br>
On 16 November 2015 at 11:44, Mark Carter <<a href="mailto:alt.mcarter@gmail.com">alt.mcarter@gmail.com</a>> wrote:<br>
<br>
> Suppose I want to use an argument twice, as for example in the expression:<br>
> (\x -> (pred1 x) and (pred2 x))<br>
><br>
> Is there a shorter way of doing this?<br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20151116/78b641a6/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20151116/78b641a6/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Beginners Digest, Vol 89, Issue 28<br>
*****************************************<br>
</blockquote></div>