On Sun, Jun 14, 2009 at 2:06 AM, Fernan Bolando <span dir="ltr">&lt;<a href="mailto:fernanbolando@mailc.net">fernanbolando@mailc.net</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all<br>
<br>
If I have a number of list<br>
example<br>
list1 = [2,3]<br>
list2 = [1,2]<br>
list3 = [2,3,4]<br>
list4 = [1,2,3]<br>
<br>
I want to create a list from the list above with n elements,<br>
non-repeating and each elements index represents 1 of the elements<br>
from the corresponding list so for the above input I would get.<br>
<br>
a = [3,2,4,1]<br>
<br>
ofcourse there may be several set that will satisfy the problem, so a<br>
list of list that satisfies would be good.</blockquote><div><br>I will rephrase the problem, since some folks seem to be having a hard time understanding it.<br><br>You want a list of four elements.  The first element comes from list1, the second from list2, ....   And there should be no duplicates in the solution.<br>
<br>To start you off, here is a selection function, which computes all such lists, but does not remove duplicates.<br><br>select :: [[a]] -&gt; [[a]]<br>select [] = [[]]<br>select (xs:xss) = [ x:rest | y &lt;- xs; rest &lt;- select xss ]<br>
<br>Filtering out the duplicate-free lists should not be a problem.<br><br>Note: this is not an efficient solution, it is just to get you started.  Making it efficient will require understanding and modifying the above select function, which ought to be an educational experience :-)<br>
<br>Luke<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
How do I do this in haskell? or is there a code snippet that seems to<br>
work similarly?<br>
<br>
thanks<br>
fernan<br>
<font color="#888888"><br>
--<br>
<a href="http://www.fernski.com" target="_blank">http://www.fernski.com</a><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></blockquote></div><br>