当前位置:网站首页>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.
边栏推荐
- The best time to buy and sell stocks includes handling charges (leetcode-714)
- The best time to buy and sell stocks Ⅳ (leetcode-188)
- Arduino- how to light the LED?
- [STM32 learning] (18) STM32 realizes LCD12864 display - parallel implementation of 8-bit bus
- Google Earth engine - QA in Landsat 5 toa dataset_ Pixel and QA_ Radsat band
- Home raiding II (leetcode-213)
- 给你的网站加一个爱发电角标
- [STM32 learning] (17) STM32 realizes LCD12864 display serial implementation
- zoj-Swordfish-2022-5-6
- Raspberry Pie: /bin/sh: 1: bison: not found
猜你喜欢

Uniapp calendar component

Query about operating system security patch information
![[correcting Hongming] what? I forgot to take the](/img/41/c8fa6380ab63949ae6d904fdbb005c.png)
[correcting Hongming] what? I forgot to take the "math required course"!

Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K

Where is the bitbucket clone address

zoj1137+作业1--2022年5月28日
![[robot learning] mechanism kinematics analysis and MATLAB simulation (3D model +word report +matlab program)](/img/dd/d29a5be7306580ad388ba6487d230f.png)
[robot learning] mechanism kinematics analysis and MATLAB simulation (3D model +word report +matlab program)
![Raspberry Pie: [failed] failed to start /etc/rc local Compatibility.](/img/c3/d648cea4e8eef20a221dc034ecfc1d.png)
Raspberry Pie: [failed] failed to start /etc/rc local Compatibility.

2022, enterprise unified process platform design and integration specifications refer to thubierv0.1

zoj-Swordfish-2022-5-6
随机推荐
[correcting Hongming] what? I forgot to take the "math required course"!
Is CITIC Securities a safe and reliable securities firm? How to open an account?
What did zoneawareloadbalancer of ribbon and its parent class do?
Arduino- how to light the LED?
Raspberry Pie:: no space left on device
The optimal time to buy and sell stocks includes the freezing period (leetcode-309)
LiteOS_ a - SYS_ The run() function is missing a header file.
The paper of gaojingjian center was selected into the ACL 2022 of the international summit to further expand the privacy computing capacity of Chang'an chain
Looting (leetcode-198)
JS 84*148=b6a8 how many decimal places can you make both sides equal
关联规则--2022年7月10日
Jenkins deploys the project and prompts that the module package defined by him cannot be found
TypeError: Object of type ‘int32‘ is not JSON serializable
Application of for loop
Homologous policy solutions
[STM32 learning] (14) two 74HC595 controls four nixie tube displays
Build a live broadcast platform based on webrtc
Add a love power logo to your website
多表查询之子查询_单行单列情况
Association Rules -- July 10, 2022