Map and filter functionality using reduce - Swift