Skip to content

Instantly share code, notes, and snippets.

@attatrol
Last active February 10, 2016 21:44
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 attatrol/62f017acae2cff99fe1c to your computer and use it in GitHub Desktop.
Save attatrol/62f017acae2cff99fe1c to your computer and use it in GitHub Desktop.
void f0() {
//NP(ternary) = 2
int i = true ? 1 : 2;
//NP(cycle) = 2
for(; i<10; i++) {
}
}
//NP(f0) = 4
void f1() {
//NP(cycle) = NP(expr) + NP(range) + 1 = 2 + 1 + 1 = 4
for(int i = true ? 1 : 2; i < 10; i++) {
}
}
//NP(f1) = 4
//f0 and f1 are equivalent
void f2() {
//NP(cycle) = NP(expr) + NP(range) + 1 = 2 + 1 + 1 = 4
for(int i = 1; i < true ? 10 : 15; i++) {
//NP(range) = 1
}
}
//NP(f2) = 4
void f3() {
int j = 15;
//NP(cycle) = NP(expr) + NP(range) + 1 = 0 + 2 + 1 = 3
for(int i = 1; i < j; i++) {
//NP(range) = NP(ternary) = 2
int j = true ? 10 : 15;
}
}
//NP(f3) = 3
//NP(f2) != NP(f3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment