[erlang-questions] omaha poker hand permutations

Vincenzo Maggio <>
Tue Aug 16 16:43:32 CEST 2011


It's right for this case, but IMHO difficult to read through and mantain.

> From: 
> Date: Tue, 16 Aug 2011 16:38:43 +0200
> To: 
> CC: 
> Subject: Re: [erlang-questions] omaha poker hand permutations
> 
> Can't you just do:
> 
> L4 = [ {A, B} || A <- L3, B <- L3, A < B].
> 
> This adds a strict ordering on the returned pairs.
> 
> - Marc
> 
> 
> 
> On 16 aug 2011, at 16:35, Dmitry Demeshchuk wrote:
> 
> > Lis comprehensions are a combination of map and filter. But I think
> > you need lists:foldl/3 here, or just a custom reducing function. So
> > the answer is no.
> > 
> > On Tue, Aug 16, 2011 at 6:27 PM, Joel Reymont <> wrote:
> >> The problem can be reduced to the following:
> >> 
> >> 5> L3 = ["AD", "AH", "AS", "QS"].
> >> ["AD","AH","AS","QS"]
> >> 
> >> 6> L4 = [ {A, B} || A <- L3, B <- L3, A /= B].
> >> [{"AD","AH"},
> >>  {"AD","AS"},
> >>  {"AD","QS"},
> >>  {"AH","AD"},
> >>  {"AH","AS"},
> >>  {"AH","QS"},
> >>  {"AS","AD"},
> >>  {"AS","AH"},
> >>  {"AS","QS"},
> >>  {"QS","AD"},
> >>  {"QS","AH"},
> >>  {"QS","AS"}]
> >> 
> >> Note the duplicate pairs of AD, AH and AH, AD.
> >> 
> >> Can these be eliminated inside the list comprehension itself?
> >> 
> >>        Thanks, Joel
> >> 
> >> --------------------------------------------------------------------------
> >> - for hire: mac osx device driver ninja, kernel extensions and usb drivers
> >> ---------------------+------------+---------------------------------------
> >> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
> >> ---------------------+------------+---------------------------------------
> >> 
> >> 
> >> 
> >> _______________________________________________
> >> erlang-questions mailing list
> >> 
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >> 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > Dmitry Demeshchuk
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110816/a10a23cc/attachment.html>


More information about the erlang-questions mailing list