相关推荐
-module(helloworld).
-export([start/0]).
start() ->
A = 5,
B = 6,
if
A == B ->
io:fwrite("True");
-module(helloworld).
-export([start/0]).
start() ->
A = 5,
B = 6,
if
A == B ->
io:fwrite("A is equal to B");
-module(helloworld).
-export([start/0]).
start() ->
A = 4,
B = 6,
if
A < B ->
if
A > 5 ->
-module(helloworld).
-export([start/0]).
start() ->
A = 5,
case A of
5 -> io:fwrite("The value of A is 5");
-module(helloworld).
-export([add/2,start/0]).
add(X,Y) ->
Z = X+Y,
io:fwrite("~w~n",[Z]).
% Erlang整数
-module(helloworld).
-export([start/0]).
start() ->
io:fwrite("~w",[1+1]).
-module(helloworld).
-export([tail_reverse/2,start/0]).
tail_reverse(L) -> tail_reverse(L,[]).
tail_reverse([],Acc) -> Acc;
-module(helloworld).
-export([duplicate/2,start/0]).
duplicate(0,_) ->
[];
duplicate(N,Term) when N > 0 ->
-module(helloworld).
-export([tail_len/1,tail_len/2,start/0]).
tail_len(L) -> tail_len(L,0).
tail_len([], Acc) -> Acc;
-module(helloworld).
-export([len/1,start/0]).
len([]) -> 0;
len([_|T]) -> 1 + len(T).
start() ->
-module(helloworld).
-export([fac/1,start/0]).
fac(N) when N == 0 -> 1;
fac(N) when N > 0 -> N*fac(N-1).
-module(helloworld).
-import(io,[fwrite/1]).
-export([start/0]).
start() ->
fwrite("Hello, world!\\n").
-module(helloworld).
-author("TutorialPoint").
-version("1.0").
-export([start/0]).
-module(helloworld).
-author("TutorialPoint").
-version("1.0").
-export([start/0]).
% Erlang模块定义 - helloworld
-module(helloworld).
-export([start/0]).
start() ->
io:fwrite("Hello World").
-module(helloworld).
-export([add/1,start/0]).
add(X) when X>3 ->
io:fwrite("~w~n",[X]).
-module(helloworld).
-export([add/2,add/3,start/0]).
add(X,Y) ->
Z = X+Y,
io:fwrite("~w~n",[Z]).
-module(helloworld).
-export([start/0]).
start() ->
Fn = fun() ->
io:fwrite("Anonymous Function") end,
% 关系运算符
-module(helloworld).
-export([start/0]).
start() ->
io:fwrite("~w~n",[3==2]),
-module(helloworld).
-export([start/0]).
start() ->
io:fwrite("~w~n",[true or false]),
io:fwrite("~w~n",[true and false]),