[Haskell-beginners] Pattern Matching for record syntax

Jeon-Young Kang jykang22 at gmail.com
Thu Jan 7 23:02:12 UTC 2016


I  figured out.. Thank you so much.

On Thu, Jan 7, 2016 at 5:51 PM, Magnus Therning <magnus at therning.org> wrote:

>
> Jeon-Young Kang writes:
>
> > For pattern matching.. I implemented like this.
> >
> > compareName a (Person name age)
> >         | (a == name) = age
> >
> > but, I got stuck how to apply pattern matching for the two lists.
> > i.e., both names and persons are lists.
> >
> > I really appreciate your advice..
>
> Something like this works:
>
>     map age $ filter (\ p -> (name p) `elem` names) persons
>
> /M
>
> --
> Magnus Therning              OpenPGP: 0x927912051716CE39
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
>
> Finagle's Fifth Law:
> Always draw your curves, then plot your readings.
>
> _______________________________________________
> 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/20160107/3eb5f0e0/attachment.html>


More information about the Beginners mailing list