so this is a bit of a poser, I can do it without using filter, but I'd like to explore the possibilities.
consider an array of arrays :
var array01 : [String] = ["one","two","three","four","bob","mary","adam","cecil","lambert","fitswidget","oar","twelve"]
var array02 : [String] = ["one","two","three","four","marley","dee","sevil","pour","cdc","astec","plar","been"]
var array03 : [String] = ["one","two","three","four","rent","on","gret","jesus","wonder","see","mixed","poop"]
var array04 : [String] = ["one","two","three","four","gidget","oops","fentonil","john","cerci","may","pole","gouge"]
var array05 : [String] = ["one","two","three","four"]
var glomArray = [array01, array02, array03, array04, array05]the goal is to get an array of elements that are common to all o fthe subArrays.
we can get a flat map of the glomArray:
let fmap = glomArray.flatMap({$0})then we can count how many times each element of array01 shows up in the fmap array (no code because it's fairly obvious)
I was wondering if I could do this with a filter. and what I came up with won't work. But could it work?
var hitArray = array01.filter({ fmap.filter({$0 == $0}).count == 5 })what I'm trying to do is filter array01, and count how many times it shows up in fmap. if the element shows up 5 times, the evaluation is true, and that element is included in the array.
I could easily write a test function, that would evaluate that. What I'm nterested in here, is whether or not it is possible to perform this calulation with a filter, embedded inside another filter?