Memoization is a very interesting topic. Here is an example involving the handling of a recursively defined function:
https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/MISC/memoization.dats I will try to write about it once I get some free time. On Wednesday, July 13, 2016 at 9:29:42 AM UTC-4, Artyom Shalkhakov wrote: > > Hello Steinway, > > On Monday, July 11, 2016 at 7:15:10 AM UTC+6, Steinway Wu wrote: >> >> Hi, >> >> In a practice, I encountered a problem of memorizing functions. Given a >> function `f`, a memorized version of `f`, called `memo f` should cache the >> results of `f` applying on some `input`. I tried a demo here >> https://glot.io/snippets/egflakau5h >> <https://www.google.com/url?q=https%3A%2F%2Fglot.io%2Fsnippets%2Fegflakau5h&sa=D&sntz=1&usg=AFQjCNGtSHUrsoRyTWQSVUv0fTRp4Ue6dw>, >> >> which shows a generic implementation of the function `memo0` (for >> memorizing a function of no arguments) and `memo1` (for memorizing a >> function with one argument). Comments are welcomed. >> > > Thanks for the example! Reminds of hash-consing technique (say you memoize > unary constructors for a datatype). > > I've changed the code a tiny bit to make the [memo1] function return type > fully generic. Here's the code: > > https://glot.io/snippets/egid4pae37 > -- You received this message because you are subscribed to the Google Groups "ats-lang-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/ats-lang-users. To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/499fbf3a-e1af-46b0-bb28-c5840df05958%40googlegroups.com.
