:- parallel fork/2. fork(Max, Max). ... fork(Max, 2). fork(Max, 1).Operationally, the advantage of fork/2 compared to a recursive definition like
:- parallel bfork/2. bfork(Max, Max). bfork(Max, I) :- Max>1, Max1 is Max-1, bfork(Max1, I).is that fork/2 creates only a single wide choice point instead of Max binary ones. This improves efficiency, especially for parallel execution.
% peclipse -w 3 [eclipse 1]: fork(5,X), get_flag(worker, W). X = 5 W = 1 More? (;) X = 3 W = 3 More? (;) X = 4 W = 2 More? (;) X = 2 W = 1 More? (;) X = 1 W = 3 More? (;) no (more) solution.