Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare fun {Producent X}
- {Delay ({OS.rand} mod 1000)}
- if X \= 0
- then ({OS.rand} mod 100)+1 | {Producent X-1}
- else nil
- end
- end
- declare fun {Przetwornik A1 A2 A3}
- {Delay ({OS.rand} mod 1000)}
- case A1
- of H|T then case A2
- of Q|W then case A3
- of E|R then if {Abs (Q-E)} < H then
- if H < (Q+E) then (H#Q#E)|{Przetwornik T W R}
- else {Przetwornik T W R} end
- else {Przetwornik T W R} end
- [] nil then nil
- end
- [] nil then nil
- end
- [] nil then nil
- end
- end
- declare fun {Konsument L}
- {Delay ({OS.rand} mod 1000)}
- case L
- of (A#B#C)|T then local P = {IntToFloat (A+B+C)}/2. in
- {Sqrt P*(P-{IntToFloat A})*(P-{IntToFloat B})*(P-{IntToFloat C})}|{Konsument T}
- end
- [] nil then nil
- end
- end
- declare fun {Suma X Y Z}
- local P1
- thread P1 = {Konsument {Przetwornik {Producent X} {Producent Y} {Producent Z}}} end
- thread {Browse P1} end
- in
- local fun {Rek L Acc}
- case L
- of H|T then {Rek T Acc+H}
- [] nil then Acc
- end
- end
- in {Rek P1 0.0}
- end
- end
- end
- {Browse {Suma 10 10 10}}
- local P1 P2 P3 S1 S2 in
- thread P1 = {Producent 10} end
- thread {Browse P1} end
- thread P2 = {Producent 10} end
- thread {Browse P2} end
- thread P3 = {Producent 10} end
- thread {Browse P3} end
- thread S1 = {Przetwornik P1 P2 P3} end
- thread {Browse S1} end
- thread S2 = {Konsument S1} end
- thread {Browse S2} end
- end
Add Comment
Please, Sign In to add comment