在shell中定义erlang函数 [英] Defining erlang functions in the shell

查看:124
本文介绍了在shell中定义erlang函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

是否有任何方法可以从Erlang shell中定义Erlang函数,而不是从erl文件?但它是痛苦的。以下是Erlang条款中的lambda函数声明(aka fun )。


1 > F = fun(X) - > X + 2 end 。



#Fun< erl_eval.6.13229925>


看看这个 post 。您甚至可以输入模块的价值声明,如果你需要的话。换句话说,是的,你可以声明函数。


Is there any way to define an Erlang function from within the Erlang shell instead of from an erl file?

解决方案

Yes but it is painful. Below is a "lambda function declaration" (aka fun in Erlang terms).

1> F=fun(X) -> X+2 end.

#Fun <erl_eval.6.13229925>

Have a look at this post. You can even enter a module's worth of declaration if you ever needed. In other words, yes you can declare functions.

这篇关于在shell中定义erlang函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆