I am a beginner trying to make an anonymous function that takes two parameters. It needs to use guards to check if the two values are both strings or integers. If they both are strings, those strings need to be combined and printed. If they are both integers, they need to be added together and printed.
However, I am getting an error with different arities when using two is_bitstring and is_integer. Is the code below even possible using one anonymous function?
f = fn
x, y when is_bitstring(x) and is_bitstring(y) -> IO.puts x <> y
x, y when is_integer(x) and is_integer(y) -> IO.puts x + y
_ -> IO.puts "Both parameters are not strings"
end
Thank you!