| Ruud H.G. van Tol on Tue, 10 Feb 2026 07:57:54 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Is short-circuit evaluation possible with parfor() ? |
On 2026-02-10 07:23, Ruud H.G. van Tol wrote:
? upto(lim)= [ n |n<-[1..lim], isok3(n) ]; ? upto(200) cpu time = 8,714 ms, real time = 1,086 ms.%30 = [18, 23, 24, 32, 50, 78, 86, 88, 115, 118, 131, 133, 137, 143, 145, 146, 149, 152, 153, 157, 159, 162, 165, 190]BTW, for the OEIS-entry, such an "upto" (or "a_upto") is IMO preferred over any code-example that uses print1.
Alternatively: first(nn)= my(n=0); vector(nn, i, while(!isok3(n++), ); n) ? first(24) cpu time = 6,632 ms, real time = 848 ms.%40 = [18, 23, 24, 32, 50, 78, 86, 88, 115, 118, 131, 133, 137, 143, 145, 146, 149, 152, 153, 157, 159, 162, 165, 190]
Beware: unfair time comparison. :) -- Ruud