Swift functional programming inspired by Erlang list processing