Create a "Hello world!" in Erlang !" Program

Source: Internet
Author: User

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.

.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.