scala: figured out an efficient functional union!