I'm trying to create a function that generates a set of sets of tuples, but I'm new to Haskell and don't know how to implement it. Here's pseudocode of what I'd like my code to do (I'll use {} to denote set):
mySet :: Int -> {{(Int,Int,Int,Int,Int)}}
mySet n = { {a_1,a_2,...,a_n} | P(a_1,a_2,...,a_n) }
The part I've written so far is the list that I'm taking each a_i from. The code is
firstList :: Int -> [(Int,Int,Int,Int,Int)]
firstList n = [(a,b,c,d,e) | a <- [0,1,(-1)], b <- [1..n], c <- [1..(2*n)], d <- [1..n], e <- [1..(2*n)]]
Basically, I want to have mySet take from the list of the form
[(a1,a2,a3,a4,a5),(b1,b2,b3,b4,b5),...]
and create a list (or set, actually) that, for example when n=3, looks like
[[(a1,a2,a3,a4,a5),(b1,b2,b3,b4,b5),(c1,c2,c3,c4,c5)],[(d1,d2,d3,d4,d5),(e1,e2,e3,e4,e5),(f1,f2,f3,f4,f5)],...]
As far as implementations go, I'd prefer readability over speed, but ideally I'd like both.
[(1,2,3,4,5), (6,7,8,9,10), ...]and you wantmySet nto return a subset of this list depending on a predicateP? Then why aren't you writing[x | x <- originalList, predicate x]to check one tuple at a time? Or is the5in5-upleparametric? In this case note that you actually cannot do anything really generic because3-uples are a different type from5-uples.