<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
It's right for this case, but IMHO difficult to read through and mantain.<br><br><div>> From: marc@worrell.nl<br>> Date: Tue, 16 Aug 2011 16:38:43 +0200<br>> To: demeshchuk@gmail.com<br>> CC: erlang-questions@erlang.org<br>> Subject: Re: [erlang-questions] omaha poker hand permutations<br>> <br>> Can't you just do:<br>> <br>> L4 = [ {A, B} || A <- L3, B <- L3, A < B].<br>> <br>> This adds a strict ordering on the returned pairs.<br>> <br>> - Marc<br>> <br>> <br>> <br>> On 16 aug 2011, at 16:35, Dmitry Demeshchuk wrote:<br>> <br>> > Lis comprehensions are a combination of map and filter. But I think<br>> > you need lists:foldl/3 here, or just a custom reducing function. So<br>> > the answer is no.<br>> > <br>> > On Tue, Aug 16, 2011 at 6:27 PM, Joel Reymont <joelr1@gmail.com> wrote:<br>> >> The problem can be reduced to the following:<br>> >> <br>> >> 5> L3 = ["AD", "AH", "AS", "QS"].<br>> >> ["AD","AH","AS","QS"]<br>> >> <br>> >> 6> L4 = [ {A, B} || A <- L3, B <- L3, A /= B].<br>> >> [{"AD","AH"},<br>> >> {"AD","AS"},<br>> >> {"AD","QS"},<br>> >> {"AH","AD"},<br>> >> {"AH","AS"},<br>> >> {"AH","QS"},<br>> >> {"AS","AD"},<br>> >> {"AS","AH"},<br>> >> {"AS","QS"},<br>> >> {"QS","AD"},<br>> >> {"QS","AH"},<br>> >> {"QS","AS"}]<br>> >> <br>> >> Note the duplicate pairs of AD, AH and AH, AD.<br>> >> <br>> >> Can these be eliminated inside the list comprehension itself?<br>> >> <br>> >> Thanks, Joel<br>> >> <br>> >> --------------------------------------------------------------------------<br>> >> - for hire: mac osx device driver ninja, kernel extensions and usb drivers<br>> >> ---------------------+------------+---------------------------------------<br>> >> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont<br>> >> ---------------------+------------+---------------------------------------<br>> >> <br>> >> <br>> >> <br>> >> _______________________________________________<br>> >> erlang-questions mailing list<br>> >> erlang-questions@erlang.org<br>> >> http://erlang.org/mailman/listinfo/erlang-questions<br>> >> <br>> > <br>> > <br>> > <br>> > -- <br>> > Best regards,<br>> > Dmitry Demeshchuk<br>> > _______________________________________________<br>> > erlang-questions mailing list<br>> > erlang-questions@erlang.org<br>> > http://erlang.org/mailman/listinfo/erlang-questions<br>> <br>> _______________________________________________<br>> erlang-questions mailing list<br>> erlang-questions@erlang.org<br>> http://erlang.org/mailman/listinfo/erlang-questions<br></div> </div></body>
</html>