From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d74d61525ce986e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-22 05:52:12 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Implementing Memorize Date: Wed, 22 Oct 2003 12:52:12 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1066827132 4900 217.17.192.37 (22 Oct 2003 12:52:12 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 22 Oct 2003 12:52:12 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:1416 Date: 2003-10-22T12:52:12+00:00 List-Id: * Marius Amado Alves wrote: > On Wed, 2003-10-22 at 11:33, Lutz Donnerhacke wrote: >> * Lutz Donnerhacke wrote: >> > Calculating Fibbonacci numbers recursivly is easy but braindead. Languages >> > with access to the symbol table at execution time are able to change the the >> > reccuring call with a memorize wrapper which returns already computed values >> > immediatly instead of recalculating them. In the referenced article I wrote >> > an C-Implementation of such a wrapper. Now I'm looking for a more elegant >> > version in Ada. > > So your problem is generating the Fibonaci number of a given natural N. No. Fib is only an application for the more general pattern Memorize. > I would not use recursive calls here because call stack space is usually > shorter than the range of naturals. I would use increments in a loop. The Memorize package should get the function to be computed as a generic parameter. So you can't assume anything about the parameters used. > Took a look at your code. I think you're failing to set the Valid > component. Yep. Code in progress.