更新时间:2022-06-27 00:20:23
正确的是,您必须导出p和g 。您可以使用apply / 3来调用它。
It is correct that you have to export p and g. You can then use apply/3 to call it.
erlang:apply(sample, p, [])
只有乐趣值可用于Fun(...)语法。你正在传递一个原子值。原子是错误消息的坏功能。你可以做类似于
Only fun-values are usable with the Fun(...) syntax. You are passing in an atom-value. An atom is a 'bad function' as the error message go. You could do something similar to
xyz(p) -> fun p/0;
xyz(g) -> fun g/0.
然后继续调用
Fun = xyz(p),
Fun()