Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Producer Consumer Filter in
- fun {Producer N}
- fun {Aux X}
- if X==N then X|nil
- else X|{Aux X+1}
- end
- end
- in
- {Aux 1}
- end
- fun {Consumer S}
- fun {Aux S Sum}
- case S
- of H|T then {Aux T Sum+H}
- [] nil then Sum
- end
- end
- in
- {Aux S 0}
- end
- fun {Filter S}
- case S
- of H|T then
- if H mod 2 == 0 then {Filter T}
- else H|{Filter T}
- end
- [] nil then nil
- end
- end
- local S I R in
- thread S = {Producer 20} end
- thread I = {Filter S} end
- thread R = {Consumer I} end
- {Browse R}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement