Created
December 18, 2019 15:29
-
-
Save ythirion/903b87d85c58436d91f1d8a551718560 to your computer and use it in GitHub Desktop.
memoization
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
static Func<string, string> GenerateGuidForUser = user => user + ":" + Guid.NewGuid(); | |
static Func<string, string> GenerateGuidForUserMemoized = memo(GenerateGuidForUser); | |
[Fact] | |
public void memoization_example() | |
{ | |
GenerateGuidForUserMemoized("spongebob");// spongebob:e431b439-3397-4016-8d2e-e4629e51bf62 | |
GenerateGuidForUserMemoized("buzz");// buzz:50c4ee49-7d74-472c-acc8-fd0f593fccfe | |
GenerateGuidForUserMemoized("spongebob");// spongebob:e431b439-3397-4016-8d2e-e4629e51bf62 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment