← parentheses operator page · general/parentheses/sc/nested_parentheses

Nested parentheses 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

Nested parentheses, ( SC_1 - SC_2 / (SC_3 + SC_4) ) * SC_5 with SC_1 = 20, SC_2 = 10, SC_3 = 2, SC_4 = 3 and SC_5 = 3: the inner ones are evaluated first.

Manual:

Parentheses: "If more parentheses are nested, the inner parentheses are evaluated first, for example ( 20 - 10 / (2 + 3) ) * 3 would give 54."

Expected:

2 + 3 = 5, 10 / 5 = 2, 20 - 2 = 18 and 18 * 3 = 54: SC_r = 54, a Number, as a division gives a number (Division page) and so does an operation with a number operand (Subtraction and Multiplication pages).

script.vtl ⇩

SC_r := ( SC_1 - SC_2 / (SC_3 + SC_4) ) * SC_5;

input/scalars.csv ⇩

SC_1SC_2SC_3SC_4SC_5
2010233

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "Integer"},
    {"name": "SC_2", "type": "Integer"},
    {"name": "SC_3", "type": "Integer"},
    {"name": "SC_4", "type": "Integer"},
    {"name": "SC_5", "type": "Integer"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Number", "value": "54"}
  ]
}