Chinaunix首页 | 论坛 | 博客
  • 博客访问: 376291
  • 博文数量: 124
  • 博客积分: 2911
  • 博客等级: 少校
  • 技术积分: 1050
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-15 15:57
文章分类

全部博文(124)

文章存档

2012年(6)

2011年(26)

2010年(92)

我的朋友

分类:

2010-07-14 17:57:47

Gcc 4.4.4 -> objective-C

1.Fc13 2.6.34 + gcc4.4.4
2.yum install gnustep* (or maybe adding "yum install gcc-objc")

For C codes:
3.gcc -x objective-c -o

For objective -c codes:
3.gcc -o -L /GNUstep/System/Library/Libraries/ -lobjc -lgnustep-base

FC13 2.6.34 -> Erlang
Before installing, ensure uv install apps. below:
GNU make/GNU C compiler/Perl /OpenSSL / X Windows

1.yum install erlang
2.Shell: enter "erl" into Erlang Shell.
3.Quit: Ctrl+G -> q

4.Put the following into a text file:

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

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

Explaination:

%%1:Erlang程序文件称为module(模块)。第一行就是告诉我们这个模块的名字。

当我们在使用另一个模块中的函数时,我们使用下面的语法 module_name:function_name(arguments).所以:test:fac(10).
意味着我们从test模块中调用一个叫做fac的函数,并且带有参数“10”.

%%2:-export([fac/1]):导出一个带有一个参数的函数fac

2nd Example:

-module(tut1).
-export([fac/1, mult/2]).

fac(1) ->
1;

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

mult(X, Y) ->
X * Y.

save it as test.erl in a directory that’s easy to get to with the Terminal. Then, from the Terminal, cd into that directory and type erl (which, if everything worked right, should start the Erlang command-line interpreter). From the interpreter, run the following commands:

1> c(test).
{ok,test}

2> test:fac(20).
2432902008176640000

3> test:fac(40).
815915283247897734345611269596115894272000000000

阅读(465) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~