[Haskell-beginners] Is there an idiom for this?

鲍凯文 traqueofziche at gmail.com
Mon Nov 16 21:35:05 UTC 2015


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, <beginners-request at haskell.org> wrote:

> Send Beginners mailing list submissions to
>         beginners at 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 at haskell.org
>
> You can reach the person managing the list at
>         beginners-owner at 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 <alt.mcarter at gmail.com>
> To: beginners at haskell.org
> Subject: [Haskell-beginners] Is there an idiom for this?
> Message-ID: <5649C1A3.1010901 at 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 <objitsu at gmail.com>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
>         beginner-level topics related to Haskell <beginners at haskell.org>
> Subject: Re: [Haskell-beginners] Is there an idiom for this?
> Message-ID:
>         <CAEiEuULHWhechDwUF417Rnr55RDrEVUFVOgiQ6=
> 5-8jux3pXyg at mail.gmail.com>
> 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 <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
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20151116/78b641a6/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 89, Issue 28
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151116/dcf4a0d2/attachment.html>


More information about the Beginners mailing list