4/4

isBetween: readings outside the safe range

Medium

A sensor logs readings. Return the ones that are not strictly between ri!low and ri!high, in the order they were logged.

A reading exactly on a limit counts as out of range, because the range excludes both ends.

For {2, 5, 9} with a range of 1 to 6 the answer is {9}.

Watch out

  • When every reading is in range, the answer is an empty list.

Inputs

  • ri!readings — List of Integer
  • ri!low — Number (Integer)
  • ri!high — Number (Integer)

ri! Rule Inputs

ri!readingsList of Integer
{
  2,
  5,
  9
}
ri!lowNumber (Integer)
1
ri!highNumber (Integer)
6

Example 1 — One reading too high

Input: ri!readings
{
  2,
  5,
  9
}
Input: ri!low
1
Input: ri!high
6
Output:
{9}

Example 2 — On both limits

Input: ri!readings
{
  1,
  3,
  6
}
Input: ri!low
1
Input: ri!high
6
Output:
{
  1,
  6
}

Example 3 — All in range

Input: ri!readings
{
  2,
  3,
  4
}
Input: ri!low
1
Input: ri!high
6
Output:
{}

Example 4 — All out of range

Input: ri!readings
{
  0,
  7
}
Input: ri!low
1
Input: ri!high
6
Output:
{
  0,
  7
}

Example 5 — Nothing logged

Input: ri!readings
{}
Input: ri!low
1
Input: ri!high
6
Output:
{}

Appian Expression Tips

  • • Use ri!variableName for rule inputs
  • • Use a!localVariables(local!x: …, body) for locals
  • • Use a!forEach(items: …, expression: fv!item) to iterate
  • • Use where() / reject(fn!isnull, list) to filter