On Sun, Jun 14, 2009 at 4:13 PM, Erik de Castro Lopo<mle...@mega-nerd.com> wrote: > Fernan Bolando wrote: > >> Hi all >> >> If I have a number of list >> example >> list1 = [2,3] >> list2 = [1,2] >> list3 = [2,3,4] >> list4 = [1,2,3] >> >> I want to create a list from the list above with n elements, >> non-repeating and each elements index represents 1 of the elements >> from the corresponding list so for the above input I would get. >> >> a = [3,2,4,1] >> >> ofcourse there may be several set that will satisfy the problem, so a >> list of list that satisfies would be good. >> >> How do I do this in haskell? or is there a code snippet that seems to >> work similarly? > > Well you could simply concatenate all the lists using the (++) operator > and then use Data.List.nub: > > http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:nub > > to remove duplicates. > Using Data.List.nub Data.List> nub [2,3,1,2,2,3,4,1,2,3] [2,3,1,4]
that is not exactly what I want. list1 only has 2,3 has elements and list2 only has elements 1,2...this means the first element should only be 2 or 3 and the second element should only have 1 or 2...etc fernan -- http://www.fernski.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe