You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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
Kenneth Wolcott
unread,
Jul 22, 2023, 1:30:46 AM7/22/23
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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?
Thanks,
Ken
Gautier write-only address
unread,
Jul 24, 2023, 5:18:28 PM7/24/23
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
> So, any resources on how to write Ada programs that take advantage of memoization?
Look here https://forum.ada-lang.io/ for discussions about Advent of Code puzzles. Some solutions use (and need, for completing in a reasonable time) memoization.
You find with HAC ( https://hacadacompiler.sourceforge.io/ ) a set of solutions (search "memoiz*" or "cache"), mostly compiling with the HAC subset.
Kenneth Wolcott
unread,
Jul 26, 2023, 12:38:04 AM7/26/23
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Thanks for the pointer to the forum.
Regarding HAC, isn't that Windows-only? I'm on a Mac (M1 chip). I'll look again at HAC.
Ken
Simon Wright
unread,
Jul 26, 2023, 3:50:05 AM7/26/23
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message