Jump to content

Loops/With multiple ranges: Difference between revisions

Line 1,765:
 
As another alternative to the first solution above, we can loop over the ranges. This avoids the concatenations and generation of the intermediate big collection (which does not really make a difference here, but would, if each collection consisted of millions of objects):
{{works with|Smalltalk/X}}<lang smalltalk>...
{
(three negated to: 3**3 by: three ) .
Line 1,781:
].
...</lang>
Notice: this creates only 8 objects and also showsdemonstrates an alternative element selection scheme, which may be more readable.
{{out}}
<pre> sum = 348173
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.