Hi Andrey,
> //NP(ternary) = 2
int i = true ? 1 : 2;
Correct.
from Npath article:
Syntax: (exprl) ? (expr2):(expr3)
NP(?)=NP((expr1))+NP((expr2)) +NP((expr3))+2.
NP(ternary) = 0 + 0 + 0 + 2 = 0
NP((expr1)) = 0 - because there are no condition operators. In article there is example that prove this.
> //NP(cycle) = 2
for(; i<10; i++) {
}
Correct.
from Npath article:
Syntax: for ((exprl); (expr2); (expr3)) (for-range)
NP(for)= NP((for-range)) + NP((expr1)) + NP((expr2)) + NP((expr3)) + 1
NP(for) = 1 + 0 + 0 + 1
> //NP(cycle) = NP(exprs) + NP(range) + 1 = 2 + 1 + 1 = 4
for(int i = true ? 1 : 2; i < 10; i++) {
}
Correct.
NP(for)= NP((for-range)) + NP((expr1)) + NP((expr2)) + NP((expr3)) + 1
NP(for) = 1 + 2 + 0 + 0 + 1 = 4
> //NP(cycle) = NP(expr) + NP(range) + 1 = 2 + 1 + 1 = 4
for(int i = 1; i < true ? 10 : 15; i++) {
//NP(range) = 1
}
Correct.
NP(for)= NP((for-range)) + NP((expr1)) + NP((expr2)) + NP((expr3)) + 1
NP(for) = 1 + 0 + 2 + 0 + 1 = 4
> //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;
}
Correct.
NP(for)= NP((for-range)) + NP((expr1)) + NP((expr2)) + NP((expr3)) + 1
NP(for) = 2 + 0 + 0 + 0 + 1 = 3
thanks,
Roman Ivanov