Created
December 18, 2013 10:02
-
-
Save einarwh/8019922 to your computer and use it in GitHub Desktop.
Default f-function for consumers, given pops and pushes.
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
public Func<EvalStack, EvalStack> CreateConsumerF(int pops, int pushes) | |
{ | |
Func<EvalStack, EvalStack> pop = stack => stack.Pop(); | |
Func<EvalStack, EvalStack> push = stack => stack.Push(false); | |
Func<EvalStack, EvalStack> result = stack => stack; | |
for (int i = 0; i < pops; i++) | |
{ | |
var fresh = result; | |
result = stack => pop(fresh(stack)); | |
} | |
for (int i = 0; i < pushes; i++) | |
{ | |
var fresh = result; | |
result = stack => push(fresh(stack)); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment