Article View: aus.stats.s
Article #178news from S-news
From: David M. Shera
Date: Tue, 12 Jan 1993 20:49
Date: Tue, 12 Jan 1993 20:49
26 lines
1199 bytes
1199 bytes
Subject: saving memory and reducing "for" loops
In order to prevent memory limit errors
sometimes I am able to use recursion.
(Actually, I still need "for" loops, but recursion saves
memory by having more returns from functions.)
This may not work for all problems, but it will for
situations that partition nicely.
FF _ function ( Data ) {
if ( Data is small enough )
Result _ whatever is needed, including "for" loops
else {
Temp _ Split ( Data ) # splits into two parts
Result1 _ FF ( Temp$Part1 )
Result2 _ FF ( Temp$Part2 )
Result _ Combine ( Result1, Result2 )
}
return ( Result )
}
You have to provide appropriate Split and Combine functions, which
may or may not be easy.
- David
shera@psych.mgh.harvard.edu
Technical Details
Message-ID:
<9301121848.AA03838@psych.mgh.harvard.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!dmssyd.syd.dms.CSIRO.AU!newsShow Full Headers
Complete Article Headers
Newsgroups: aus.stats.s Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!dmssyd.syd.dms.CSIRO.AU!news From: shera@psych.mgh.harvard.edu (David M. Shera) Subject: news from S-news Message-ID: <9301121848.AA03838@psych.mgh.harvard.edu> X-Gateway: dmssyd.syd.dms.CSIRO.AU Lines: 26 Sender: daemon@syd.dms.CSIRO.AU Organization: CSIRO Div. Maths & Stats, CSIRO Div. Applied Physics Date: Tue, 12 Jan 1993 20:49:51 GMT