help / color / mirror / Atom feed
From: Kenneth Wolcott <>
Subject: Re: memoization in Ada? Hash ADT?
Date: Fri, 21 Jul 2023 22:30:44 -0700 (PDT)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Friday, July 21, 2023 at 8:50:06 PM UTC-7, Kenneth Wolcott wrote:
> Hi; 
> I'm working on the Rosetta Code task: 
> "Stirling numbers of the second kind" 
> I have a working recursive solution written in Ada but I'd like to memoize it to cut down on the redundant and duplicative calls (similar to a recursive solution to calculating the Fibonacci sequence). 
> So I think I need a hash ADT (which I've used in Perl) but I've never used in Ada. 
> So I want to preserve the calculation of the Stirling2 for each N and K so I can do a lookup. If this were based on a single unsigned integer, an array would suffice. Maybe a 2d array would suffice? 
> Thanks, 
> Ken Wolcott

I solved the specific problem using a 2d array for caching.  This is not memoization, per se, but this works very well.  The recursive calls are now very fast as there is a maximum of one calculation per recursive call.

So, any resources on how to write Ada programs that take advantage of memoization?


  reply	other threads:[~2023-07-22  5:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-22  3:50 memoization in Ada? Hash ADT? Kenneth Wolcott
2023-07-22  5:30 ` Kenneth Wolcott [this message]
2023-07-24 21:18   ` Gautier write-only address
2023-07-26  4:38     ` Kenneth Wolcott
2023-07-26  7:50       ` Simon Wright
2023-07-26 21:36       ` Gautier write-only address
2023-07-26 22:18         ` Kenneth Wolcott
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox