How does one approach this type of concurrent stream communication program?
local InS in
{Browse {Counter InS}}
InS=a|b|a|c|_
end
One should see in the browser [a#1]|[a#1 b#1]|[a#2 b#1]|[a#2 b#1 c#1]|_
A sequential program would be trivial, but without the full definition of the InS list, I can not think of an acceptable approach. Any tips would be greatly appreciated!
I tried to implement the concurrent map function, but this definition is kind of strange
declare
fun {ConcMap Xs F A}
case Xs of nil then nil
[] X|Xr then thread {F X A} end|{ConcMap Xr F X|A}
end
end
local Xs Ys in
Xs=a|b|c|d|_
thread Ys={ConcMap Xs fun {$ X A} X|A end nil} end
{Browse Ys} % prints accumulated list [a]|[b a]|[c b a]|[d c b a]|_
end
it is unclear to me how to proceed further