Erlang Primer (1) Mac OS X 上配置 Erlang 開發環境

鍾超發表於2012-05-13

Erlang Primer (1) Mac OS X 上配置 Erlang 開發環境

  • Author: 柳大·Poechant(鍾超)
  • Email: zhongchao.ustc#gmail.com (# -> @)
  • Blog:Blog.CSDN.net/Poechant
  • Date: May 13th, 2012

Install

$ ./configure
$ make
$ sudo make install

Start

$ erl
Erlang R15B01 (erts-5.9.1) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1>3+4.
7
2>3*4.
12
3>hello.
hello

Factorial numbers

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

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

Try to run it:

$ erl
Erlang R15B01 (erts-5.9.1) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1> c(test)
1> .
{ok,test}
2> test:fac(20).
2432902008176640000
3> test:fac(40).
815915283247897734345611269596115894272000000000

Reference

  1. http://imata.cn/mypost/43.htm
  2. http://www.erlang.org/static/getting_started_quickly.html

-

轉載請註明來自柳大的CSDN部落格:Blog.CSDN.net/Poechant

-

相關文章