After learning a language for an hour, I still cannot implement "Hello World !" ThisProgramErlang is just like this. Even if you have been studying for an hour, you may not know how to implement "Hello World !". This articleArticleIs about how to implement "Hello World!" on Windows !" .
First install the Erlang Program (about 70 m) on the machine. This is not detailed here, so you will know it by Google.
After installation, an "Erlang" shortcut will appear on the desktop. Instead of using it here, we can directly find the installation directory of Erlang, which usually appears here: C:/program files/erlang5.7.2 ghost looks more windows.
Find the two executable files (this is the Erlang shell) and do not rush to them. Create a. txt file in the binfolder and enter the following content:
-Module (Hello ).
-Export ([sayhello/1]).
Sayhello (true)-> "Hello world! ".
Ignore the first two lines and check the left side of the first line "->", that is, sayhello (true). This is a function header, just like in C, "->" "Hello world! "Is the" value "of the function.Programming LanguageAnd Erlang is the language ). In addition, do not forget to add a period to indicate the end Of the function (this is the habit of Erlang ). Okay. Save and close the file with hello. erl as the file name.
Run "maid. Enter
C (Hello ).
And press Enter.
Note: Do not forget the period. If it succeeds, we will receive the {OK, hello} prompt. The role of this step isCodeCompile (the Erlang program must be compiled before it can run). The newly created hello. Beam file is the compiled file. Enter
Hello: sayhello (true ).
And press Enter.
Then we will see
"Hello world! "
"Hello: sayhello (true)." indicates that the sayhello function in the hello module is called.
.