corner

WWW www.erlang.org www.erlang.se
Google
Home

· News
· About erlang.org
· Downloads
· Links and activities
· FAQs + mailing lists
· Enhancements
· Getting started
· Documentation
· Examples
· User contributions
· Mirrors



For comments or questions about this site, contact webmaster@erlang.org
     

Starting erlang

If you are running a unix system type "erl" or, if you are running on windows-95 or NT start Erlang by clicking on the Erlang start icon. You should see something like this:


os prompt > erl
Erlang (JAM) emulator version 4.7.3.3
 
Eshell V4.7.3.3  (abort with ^G)
1> 

      

The ">" prompt means the system is waiting for input.

Using Erlang as a calculator



1> 2131836812671*12937192739173917823.
27579983733990928813319999135233
2>

      

Remember to terminate every expression with a DOT followed by a whitespace!

Editing previous expressions

Previous expressions can be retrieved and edited using simple emacs line editing commands. The most common of these are:

  • ^P fetch the previous line.
  • ^N fetch the next line.
  • ^A Go to the beginning of the current line.
  • ^E Go to the end of the current line.
  • ^D Delete the character under the cursor.
  • ^F Go forward by one character.
  • ^B Go Back by one character.
  • Return Evaluate the current command.

Note: ^X means press Control + X

Try typing Control+P to see what happens.

Compiling your first program

Type the following into a file using your favorite text editor:


-module(test).
-export([fac/1]).

fac(0) -> 1;
fac(N) -> N * fac(N-1).

      

Store this in a file called test.erl The file name must be the same as the module name.

Compile the program by typing c(test) then run it:


3> c(test).
{ok,test}
30> test:fac(20).
2432902008176640000
4> test:fac(40). 
815915283247897734345611269596115894272000000000
32> 

      

Now go and write some games!

Digging deeper

 
Last updated   2007-12-07 14:03 UTC