Knowing the number of parameters of a passed function (erlang)
erlang
Solution
erlang:fun_info(Fun,arity).
For example
F = fun(A,B) -> A+B end.
#Fun<erl_eval.12.111823515>
3> erlang:fun_info(F,arity).
{arity,2}
Problem
In ERLANG: Assume we have a function f() that takes F1 as inputs where F1 is a function. Is there a way to know the number of input parameters of F1. I feel somehow there IS a solution, but I am not sure. for instance: ``` -module(high). -compile(export_all). f1() -> 1. f2(X) -> X. f3(X, Y) -> {X,Y}. run(F) -> io:format("F ~p ~n", [F]). ``` So, is there any way for function run/1 to know information about the passed function [mainly the number of input parameters of the passed function]. Note: Please be informed that this is a theoretical question. Note: is the code of apply(fun,[arguments]) available in open-source .. this may hep me I guess.