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/ee33f464-ba5c-45a3-add0-90f6d722045b%40googlegroups.com.
