如何在eshell(Erlang shell)中定义函数? [英] How to define an function in the eshell (Erlang shell)?

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

问题描述

是否可以从Erlang Shell而不是从erl文件(也称为模块)中定义Erlang函数?

Is there any way to define an Erlang function from within the Erlang shell instead of from an erl file (aka a module)?

推荐答案

是的,但是很痛苦。下面是一个 lambda函数声明(又称 fun 用Erlang表示)。

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.

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

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