RosettaCodeData/Task/Parallel-calculations/Zkl/parallel-calculations-1.zkl
2023-07-01 13:44:08 -04:00

8 lines
418 B
Text

fcn factorize(x,y,z,etc){
xyzs:=vm.arglist;
fs:=xyzs.apply(factors.strand) // queue up factorizing for x,y,...
.apply("noop") // wait for all threads to finish factoring
.apply(fcn{ (0).min(vm.arglist) }); // find minimum factor for x,y...
[0..].zip(fs).filter(fcn([(n,x)],M){ x==M }.fp1((0).max(fs))) // find max of mins
.apply('wrap([(n,_)]){ xyzs[n] }) // and pluck src from arglist
}