Create function on-the-fly?

Let say I have a tuple :

{:sum, %{x: 23}, %{y: 55 }}

Out of this how can I create the following function :

def sum({ %{x: 23}, %{y: 55 }} ), do: true

as a second question, let say I have :

{:sum, %{x: 23}, %{y: 55 }, %{when: “y > 11”} }

how do I create the function with guard ? btw. guard format could be different, say list or something else . whichever is easier ?


How about the case where the function that has to be generated has the form :

def sum({ work = %{x: 23, y: 54 } }) …