Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. % hello world program
  2. -module(helloworld).
  3. -export([start/0]).
  4. -import(string,[substr/3]).
  5. -import(lists,[nth/2]).
  6. -export([czyJestNaLiscie/2]).
  7. -import(lists,[member/2]).
  8. -import(lists,[append/1]).
  9. -export([wczytajCiagDoListy/1]).
  10. -import(lists,[reverse/1]).
  11. -import(lists,[droplast/1]).
  12. -import(lists,[last/1]).
  13. -export([odwrocenieDzialania/1]).
  14.  
  15. start() ->
  16. %wczytanie ciągu
  17. Ciag=wczytajCiagDoListy("a + b * c"),
  18. %odwrócenie kolejności w ciągu
  19. OdwroconyCiag=odwrocenieDzialania(Ciag),
  20. %io:fwrite("~p~n",[OdwroconyCiag]),
  21. %utworzenie listy operatorów + - * /
  22. Operatory=["+","-","*","/"],
  23. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. Stos = lists:foldl(fun(El, A) ->
  26. El1=El,
  27. V1=czyJestNaLiscie(El,Operatory),
  28. if
  29. V1 == true ->
  30. append([A,[El1]]);
  31.  
  32. true ->
  33. append([A])
  34. end
  35. end, [], OdwroconyCiag),
  36.  
  37. io:fwrite("Stos ~p~n", [Stos]).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement