Guest User

Untitled

a guest
May 7th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 1.57 KB | None | 0 0
  1. declare fun {Producent X}
  2.            {Delay ({OS.rand} mod 1000)}
  3.            if X \= 0
  4.            then ({OS.rand} mod 100)+1 | {Producent X-1}
  5.            else nil
  6.            end
  7.         end
  8.  
  9. declare fun {Przetwornik A1 A2 A3}
  10.        {Delay ({OS.rand} mod 1000)}
  11.        case A1
  12.        of H|T then case A2
  13.                of Q|W then case A3
  14.                    of E|R then if {Abs (Q-E)} < H then
  15.                           if H < (Q+E) then (H#Q#E)|{Przetwornik T W R}
  16.                           else {Przetwornik T W R} end
  17.                            else {Przetwornik T W R} end
  18.                    [] nil then nil
  19.                    end
  20.                [] nil then nil
  21.                end
  22.        [] nil then nil
  23.        end
  24.     end
  25.  
  26. declare fun {Konsument L}
  27.        {Delay ({OS.rand} mod 1000)}
  28.        case L
  29.        of (A#B#C)|T then local P = {IntToFloat (A+B+C)}/2. in
  30.                 {Sqrt P*(P-{IntToFloat A})*(P-{IntToFloat B})*(P-{IntToFloat C})}|{Konsument T}
  31.                  end
  32.        [] nil then nil
  33.        end
  34.     end
  35. declare fun {Suma X Y Z}
  36.        local P1
  37.           thread P1 = {Konsument {Przetwornik {Producent X} {Producent Y} {Producent Z}}} end
  38.           thread {Browse P1} end
  39.        in
  40.           local fun {Rek L Acc}
  41.                case L
  42.                of H|T then {Rek T Acc+H}
  43.                [] nil then Acc
  44.                end
  45.             end
  46.           in {Rek P1 0.0}
  47.           end
  48.        end
  49.     end
  50. {Browse {Suma 10 10 10}}         
  51.      
  52. local P1 P2 P3 S1 S2 in
  53. thread P1 = {Producent 10} end
  54. thread {Browse P1} end
  55. thread P2 = {Producent 10} end
  56. thread {Browse P2} end
  57. thread P3 = {Producent 10} end
  58. thread {Browse P3} end
  59. thread S1 = {Przetwornik P1 P2 P3} end
  60. thread {Browse S1} end
  61. thread S2 = {Konsument S1} end
  62. thread {Browse S2} end       
  63. end
Add Comment
Please, Sign In to add comment