Jump to content

Generator/Exponential: Difference between revisions

m
Line 31:
529 576 625 676 784 841 900 961 1024 1089</lang>
 
This is considerably simpler, and faster, and arguably easier to reason about, than the generator implementation. (In a quick benchmark, the direct implementation was 185 times faster and used half of the space of the generator implementation -- despite the fact that it "wasted" 3 times the computation of the generator. The generator only needed to compute squares up to 33 squared, where the quick implementation arbitrarily computed squares up to 100, but the more complicated logic of the generator also had a cost. NoteThat said, note that both implementations could be tuned for somewhat better performance (less than a factor of 10, in both cases).]
 
That saidHowever, here is an natural implementation of a generator:
 
<lang j>coclass 'generator'
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.