Skip to content

Instantly share code, notes, and snippets.

@yonatanm
Created September 19, 2012 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonatanm/3753060 to your computer and use it in GitHub Desktop.
Save yonatanm/3753060 to your computer and use it in GitHub Desktop.
a Thunk Quiz
abstract class Thunk<T> {
private boolean evaluated;
private T value;
public T get() {
if (!evaluated) {
value = compute();
evaluated = true;
}
return value;
}
abstract protected T compute();
}
@yonatanm
Copy link
Author

Provide an alternate implementation of the following class (a Thunk - http://en.wikipedia.org/wiki/Thunk_%28functional_programming%29) that uses no conditional logic. For extra credit, make it thread-safe.
send your CV to yonatan@outbrain.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment