Hi,<div><br></div><div>I&#39;m trying to come up with the most idiomatic way to generate triangle numbers that is also fast:</div><div><br></div><div>(for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j))</div><div>
<br></div><div>works but is slow because it regenerates the sums each time</div><div><br></div><div>(define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s)</div><div><br></div><div>is fast, but ugly.</div><div><br>
</div><div>How do I keep the sum in an idiomatic fashion?</div><div><br></div><div>Thanks,</div><div>-Joe</div>