SHARE
    TWEET
    Guest User

    Untitled

    a guest
    Sep 5th, 2011
    164
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Lua 0.78 KB | None | 0 0
    1. do
    2. local function lookup_memoized (val, memoized)
    3. if memoized[val] == nil then
    4. if type(val) == "table" then
    5. memoized[val] = {}
    6. memoizing_deepcopy (val, memoized, memoized[val])
    7. else
    8. return val
    9. end
    10. end
    11. return memoized[val]
    12. end
    13. function memoizing_deepcopy (src, memoized, res)
    14. local memoized = memoized or {}
    15. local res = res or {}
    16. for k, v in pairs(src) do
    17. if k ~= memoizing_deepcopy and v ~= memoizing_deepcopy then
    18. local nk = lookup_memoized (k, memoized)
    19. local nv = lookup_memoized (v, memoized)
    20. res[nk] = nv
    21. end
    22. end
    23. return res
    24. end
    25. end
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /