当前位置: 首页 > news >正文

Erlang notes[1]

文章目录

  • the basic knowledge
  • references

the basic knowledge

  1. the Erlang shell inside Erlang software sets accept bits of Erlang code to be executed and evaluated,to input the erl command can start that shell in OS.
  2. the combination key of C and Control used to stop Erlang and shell as follows.
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded(v)ersion (k)ill (D)b-tables (d)istribution
  1. a module and functions in the moudle can be easily constructed.
  2. for example,you put the following codes into the hello.erl file for defining hello moudle and add function firstly.
-module(hello).
-export([add/2]).add(X,Y) ->X + Y.
# referen

secondly, import the hello moudle and call the add functoin as follows.

> file:set_cwd("E:/learn/lerl").
ok
> c(hello).
{ok,hello}
> hello:add(11,22).
33
  1. the export statement claims some functions for exporting them to be used by other moudle through the -import indication or the calling of Module:Function.
-module(my_module).
-import(lists, [map/2, filter/2]).  % 导入 lists 模块的 map/2 和 filter/2my_func(List) ->map(fun(X) -> X * 2 end, List).  % 可以直接调用 map,而不用 lists:map
-module(my_module).my_func(List) ->lists:map(fun(X) -> X * 2 end, List).  % 显式调用 lists:map

in addtion, to compile the moudle that need to import in Erlang Shell as follows,that perhaps be more convenient.

> c(hello).
{ok,hello}
  1. Atom in Erlang,which starts with a small letter,just is a constant name that is different from variable which has value.for example:
> X=5.
5
> X.
5
> x.
x
  1. tuple is a combinated data type, which consists of elements, that can belong to either same type or various types such as {inch, Y}.one tuple data can be nested in another tuple data such as {paris, {f, 28}}.
  2. List in Erlang represent as a sets of elements surrounded by square brackets on both sides such as [1,as,X]. the | operation can seprates List into two parts such as [Head|Remain]= [1,2,3,4,5],as result of running that code , the Head is 1 and Remain is [2,3,4,5]

references

  1. https://www.erlang.org/doc/
http://www.dtcms.com/a/316381.html

相关文章:

  • 贝叶斯统计从理论到实践
  • G1垃圾回收堆内存分配问题
  • 8位mcu控制器的架构特征是什么?有哪些应用设计?
  • 单片机充电的时候电池电压会被拉高,如何检测电压?
  • 深入解析数据结构之顺序表
  • DAO治理合约开发指南:原理与Solidity实现
  • RocketMq如何保证消息的顺序性
  • 图像处理中的锚点含义
  • 【unity实战】使用unity程序化随机生成3D迷宫
  • 大学生入门:抽象 及 接口
  • 零基础人工智能学习规划之路
  • Python基础框架
  • MyBatis基础入门:Java持久层框架的技术深度解析
  • 脚手架开发-准备配置-配置文件的准备项目的一些中间件
  • Vue3 defineAsyncComponent() 函数
  • 客流人数统计准确率↑32%:陌讯多模态时序融合算法实战解析
  • 10.Linux 系统启动原理
  • 12306旅游产品数据抓取:Python+API逆向分析
  • 如何让 RAG 检索更高效?——大模型召回策略全解
  • 跨越系统孤岛:4A架构如何实现企业级一体化协同
  • 从RNN为什么长依赖遗忘到注意力机制的解决方案以及并行
  • chromedp 笔记
  • 同向双指针——滑动窗口
  • 使用公众号的消息模板给关注用户发消息
  • UNet改进(30):SageAttention在UNet中的4-Bit量化实现详解
  • UOS20操作系统关闭NUMA和透明大页(UOS20+KunPeng920)
  • mq_timedreceive系统调用及示例
  • 工业设备远程监控的 “颠覆性突破”:边缘计算网关让千里之外如在眼前
  • 【图像算法 - 09】基于深度学习的烟雾检测:从算法原理到工程实现,完整实战指南
  • 16核32G硬件服务器租用需要多少钱