-module(helloworld). -export([start/0]). start() -> Map1 = #{name => 'abc',age => 40, gender => 'M'}, io:fwrite("~w",[map_size(Map1)]).
-module(helloworld). -export([start/0]). start() -> K = {abc,50,pqr,60,{xyz,75}} , io:fwrite("~w",[tuple_size(K)]).
-module(helloworld). -export([start/0]). start() -> Bin2 = <<15,25>>, P = binary_to_list(Bin2), io:fwrite("~w",[P]).
-module(helloworld). -export([start/0]). start() -> io:fwrite(5 =< 9).
-module(helloworld). -export([start/0]). start()-> io:fwrite(monday).
-module(helloworld). -export([start/0]). start() -> io:fwrite("~w",[5+4]).
-module(helloworld). -export([addnum/2,addnum/3,start/0]). addnum(X,Y) -> Z = X+Y, io:fwrite("~w~n",[Z]). addnum(X,Y,Z) -> A = X+Y+Z, io:fwrite("~w~n",[A]). start() -> addnum(5,5), addnum(5,2,8).
-module(helloworld). -export([add/2,start/0]). add(A,B) -> C = A + B, io:fwrite("~w~n",[C]). start() -> add(5,6).
-module(helloworld). -author('[email protected]'). -vsn('2018-10-28'). -export([tipp_kod/2]). %-compile(export_all). tipp_kod(Max, Tipp_S) -> [H|T] = element(1, Tipp_S), Plus_one = lists:seq(1,Max,1) ++ [H|T], LZS = lista_zsak(Plus_one), F = lists:map(fun(X) -> X - 1 end, LZS), DUP = lists:duplicate(erlang:length(F),erlang:length([H|T])), rek(DUP, F, element(2, Tipp_S)). lista_zsak([]) -> []; lista_zsak(L) -> [M || E <-lists:usort(L), M <- [count_element(L,E)]]. rekurzio([],[],K) -> case K == 0 of true -> [[]]; false -> [] end; rekurzio(H, L, K) -> case hd(H) < 0 of true -> []; false -> case K < 0 of true -> []; false -> R = rekurzio([hd(H)-1|tl(H)], L, K), P = rekurzio(tl(H), tl(L), K-min(hd(H), hd(L))), Q = [[hd(H)|S] || S <- P], lists:append(R,Q) end end. rek(H, _, K) when K > hd(H) -> []; rek(H, L, K) when K == hd(H) -> perm(L,1,1); rek(H, L, K) when K < hd(H) -> Zsak = get_lists(lists:sum(L), rekurzio(H,L,K)), append_all(Zsak). append_all([]) -> []; append_all(O) -> perm(hd(O),1,1) ++ append_all(tl(O)). get_lists(Size, L) -> lists:filter(fun(X) -> lists:sum(X) =:= Size end, L). % perm([2, 1, 2, 4], 1, 0). perm([], _, _) -> [[]]; perm([1], N, _) -> [[N]]; perm(L, _, I) when erlang:length(L) < I -> []; perm(L, N, I) -> case hd(L) == 0 of true -> perm(tl(L), N+1, 1); false -> case lists:nth(I,L) == 0 of true -> L1 = [], L2 = perm(L, N, I+1), L1 ++ L2; false -> {L1a,L1b} = lists:split(I-1,L), L1b2 = [hd(L1b)-1|tl(L1b)], L1 = [[N+I-1|T] || T <- perm(L1a ++ L1b2, N, 1)], L2 = perm(L, N, I+1), L1 ++ L2 end end. count_element([],_) -> 0; count_element(L, E) -> H = hd(L), if H == E -> R = 1 + count_element(L--[H], E); true -> R = count_element(L--[H], E) end, R.
%hello world program -module(hello world). -export([start/o]). start()-> io:fwrite("hello, world/n")
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more