Created
October 29, 2018 02:25
-
-
Save alexlenail/d5067822731d21e026efc64c5c0d2a73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DefaultDict = (initValue) => new Proxy({}, { | |
get: (target, name) => name in target ? target[name] : | |
(target[name] = (typeof initValue === 'function' ? initValue() : initValue)) | |
}); | |
statistics = DefaultDict(() => DefaultDict(() => DefaultDict(0))); | |
// Thanks @jonathanzong! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment