I tried to write a function to get all subsequences of a list of size n, but I'm not sure how to do this.
I thought that I could probably use the built-in Data.List.subsequences and just filter out lists that don't have size n, but this seems like a pretty roundabout and inefficient way to do this, d rather don't do this if I can avoid of this, so I wonder if you have any ideas?
I want it to be something like this type
subseqofsize :: Int -> [a] -> [[a]]
For further explanation, here is an example of what I'm looking for:
subseqofsize 2 [1,2,3,3]
[[1,2],[1,3],[2,3],[1,3],[2,3],[3,3]]
In addition, I do not care about the order of anything.
source
share