当前位置:网站首页>Erlang studies abroad
Erlang studies abroad
2022-07-24 10:17:00 【Tsuit】
Long term renewal ( Probably ), Fit has been written several times Erlang Novices who don't understand the meaning of the first pile of code .
attribute
At every writing Erlang There will be something similar at the beginning of the code -module(). The sentence of , They are module attributes . Write a few commonly used predefined module attributes .
-module(modname). % This is the module declaration , among modname It must be an atom , This attribute must be the first attribute in the file ,modname It must also be the file name ,modname.erl.
-vsn(version) % Specified version number ,Version It can be any literal data type , It's no use , Generally used for analysis and description .
-import(Mod,[Name1/Arity1]). %import The declaration lists which functions need to be imported into the module . Once a function is imported from another module , There is no need to specify the module name when calling it .
-export([Name1/Arity1, Name2/Arity2, ...]). % Export the current function , Functions can only be called outside the module after being exported .
-compile(Options). % add to Options To the compiler options list
Be careful :-compile(export_all). This compiler option is often used when debugging programs . It will export all functions in the module , No more explicit use -export Marked .
for instance , It means that entering the number of years and months can automatically determine the number of days in this month ,calendar:is_leap_year() It's a built-in function , For details, please refer to Erlang Chinese Manual .
-module(tut1).
%% The following two lines are equivalent
-compile(export_all).
-export([month_length/2]).
month_length(Years,Month) ->
Leep = calendar:is_leap_year(Years),
case Month of
sep -> 30;
apr -> 30;
jun -> 30;
nov -> 30;
feb when Leep -> 29;
feb -> 28;
jan -> 31;
mar -> 31;
may -> 31;
jul -> 31;
aug -> 31;
oct -> 31;
dec -> 31
end.
边栏推荐
- 图模型2--2022-5-13
- Exception: pyqtgraph requires Qt version >= 5.12 (your version is 5.9.5)
- Activity exception lifecycle
- The best time to buy and sell stocks Ⅳ (leetcode-188)
- MySQL performance optimization (IV): how to use indexes efficiently and correctly
- Installation UMI tutorial (error reporting and solutions)
- Notes on using setupproxy
- When the hot tea is out of stock, what does the new tea drink rely on to continue its life?
- Simple parsing JSON strings with regular expressions
- Detailed explanation of uninstalling MySQL completely under Linux
猜你喜欢

Mysql database JDBC programming
![[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)](/img/6e/b7cf7a8e3296e29d61a0626e3793ea.png)
[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)

NIO知识点
![[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display](/img/f2/6fcd4b2e747b4ceb52a52eda0c1af4.png)
[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display

Zoj1137+ operation 1 -- May 28, 2022

Uniapp calendar component

Create a vertical seekbar from scratch

Analysis of Kube proxy IPVS mode
![[STM32 learning] (7) use of serial port 2 (usart2)](/img/e8/7a01cb2753f448d745e0d8712b3ebc.png)
[STM32 learning] (7) use of serial port 2 (usart2)

Jenkins deploys the project and prompts that the module package defined by him cannot be found
随机推荐
fatal: unable to commit credential store: Device or resource busy
Kotlin Advanced Grammar
Dr. water 3
Aggregate log server
Detailed explanation of uninstalling MySQL completely under Linux
Rust tokio:: task:: localset running mode
Installation UMI tutorial (error reporting and solutions)
差分约束系统---1且2--2022年5月27日
PostgreSQL rounding
Home raiding III (leetcode-337)
Home raiding II (leetcode-213)
The best time to buy and sell stocks (leetcode-121)
Erlang学习番外
Kotlin advanced
多表查询之子查询_单行单列情况
Tree array-
Raspberry Pie: /bin/sh: 1: bison: not found
CMS vulnerability recurrence - ultra vires vulnerability
ffmpeg花屏解决(修改源码,丢弃不完整帧)
note: expected ‘void * (***)(void ***)’ but argument is of type ‘void (*)(void *)’