Union of data from different functions

I am having two functions and I want to combine the result of these two functions.

defmodule Union do
  require Base

  def set1(data) do

  def set2(data) do

  def union do
    #union of set1 and set2 comes here

input of set1

[1, 2, 3, 4, 5, 6]

input for set2

[8, 4, 5, 6, 7, 8]

how can I use the union module to grab the data of set1 and set2?

mod1 and mod2 are functions not data. Also I cannot see which two modules you’re talking about here. It’s one module with 3 functions (the last one missing an end). Just like with your topic from yesterday however I’d suggest using actual examples and not pseudo code. Like what modules/data do you have and what does the expected result look like?

I have changed my question now. i might make more sense now

I mean my naive answer would be:

def union(set1, set2) do
  set1(set1) ++ set2(set2)

I however doubt that this is what you’re looking for. Given that you didn’t actually provide what set1/1 and set2/1 I’m not even sure they’re lists anymore after the function calls.

1 Like

This is what i needed,