Has anyone experimented with memo functions in LC?

Geoff Canyon Rev gcanyon+rev at gmail.com
Sat Jun 11 17:23:38 EDT 2011


I'm wondering if anyone has experimented with creating an automatic
memoization function within LC? Given that we can access argument lists, and
have "do," it seems possible, but I'm betting commas in the arguments would
be a pain. Something like this:

function m functionName
   local callHistory,callHistoryValue

   -- parse out addition arguments to m
   -- concatenate functionName & arguments into functionCallString

   if callHistory[functionCallString] is not empty then
      return callHistoryValue[functionCallString]
   end if

   -- get the function result

   put it into callHistoryValue[functionCallString]
   put 1 into callHistory[functionCallString]

   return it

end m

More information about the Use-livecode mailing list