Commit 3f239493 authored by Sergio Pérez's avatar Sergio Pérez
Browse files

Added examples folder to run e-Knife

parent 13872997
Loading
Loading
Loading
Loading

examples/bench14.erl

0 → 100644
+49 −0
Original line number Diff line number Diff line
-module(bench14).
-export([main/2]).

main(X,Y) ->
	Z = case X of
		terminate -> "the end";
		{A,B} -> {[A + B,B - A],3};
		{3,C} -> g(C);
		_ -> {20 * 3,8}
	end,
	T = 2,
	V = f(T) + h(2) + h(3),
	W = g([X,Y,{X,Y}]),
	Tuple = {Z,W,V},
	Tuple.

g(X) ->
	[_,_,{R,S}] = X,
	case R of
		[1,3] -> 21;
		[A,B] -> (A * B) / 9;
		T ->  T;
		_ -> f(4)
	end.

f(7) ->
	L = 2 + 9,
	F = L * 3,
	F + L;
f(4) -> 9;
f(2) -> 7;
f(X) -> X.

h(X) ->
	case X of
		2 -> j({2,4});
		3 ->	k([4,8]);
		1 -> l(107)
	end.

j(A) ->
	{X,_} = A,
	X.

k(B) ->
	[H|T] = B,
	H.

l(C) -> C - 1.
 No newline at end of file

examples/example.erl

0 → 100644
+13 −0
Original line number Diff line number Diff line
-module(example).
-export([main/0]).

main() ->
    {Sum,Prod} = sum_prod(10,10,0,0),
    io:format("~p",[Sum]),
    io:format("~p",[Prod]).

sum_prod(N,0,S,P) -> {S,P};
sum_prod(N,L,S,P) -> 
    S1 = S + 1,
    P1 = P + N,
    sum_prod(N,L-1,S1,P1).
 No newline at end of file