lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Dec 17, 2013 at 8:15 PM, Petite Abeille <petite.abeille@gmail.com> wrote:

In the spirit of the festive season, introducing ‘memoization a la carte’...

I love festivities! :D

(2) Basic signer

For the record, I wish I could do this -- but my paranoia leads me to distrust tostring() on types I don't "know about".  I mean __tostring might not return a unique representation of the value, or it might return empty-string...  Some odd people out there.

(3) Identity signer

Similar to the basic signer, but instead of converting values to strings, it keeps a numbered identity  map, and assigning new number to each new value (ala Sir Pogsalot).

I am credit to team :D

(4) Table signer
(5) Table identity signer

Hmm, the only problem I see here is calls like f(1, 2) and f({ 1, 2 }) look the same... :3  I added {} around expanded tables in mine :3

Share the holiday cheer, share the insanity.

Good golly that was a lot of example code XD  You.  I like you :-)

Also: Philipp pointed out that for the identity signers it needs to differentiate f(nil) from f() -- I precede the string the call is made into with select('#', ...) and this fixes that :D