2/5

where(): alert on the hours that ran too hot

Medium

A greenhouse logs one temperature reading per hour, starting at midnight: the first reading is 0:00, the second 1:00, and so on.

Return an alert line for every reading above ri!limit, in the order they happened: "2:00 - 41 degrees".

Watch out

  • Each alert needs two things: when it happened, which comes from the position, and how hot it was, which is the reading at that position.
  • where() gives you the positions; the readings are one lookup away.

Inputs

  • ri!temps — List of Integer
  • ri!limit — Integer

ri! Rule Inputs

ri!tempsList of Integer
{
  30,
  32,
  41,
  38,
  29
}
ri!limitInteger
35

Example 1 — Two hot hours

Input: ri!temps
{
  30,
  32,
  41,
  38,
  29
}
Input: ri!limit
35
Output:
{
  "2:00 - 41 degrees",
  "3:00 - 38 degrees"
}

Example 2 — Hot at midnight

Input: ri!temps
{
  40,
  30
}
Input: ri!limit
35
Output:
{"0:00 - 40 degrees"}

Example 3 — Exactly at the limit is fine

Input: ri!temps
{
  35,
  34
}
Input: ri!limit
35
Output:
{}

Example 4 — A cool day

Input: ri!temps
{
  20,
  22,
  21
}
Input: ri!limit
35
Output:
{}

Example 5 — No readings yet

Input: ri!temps
{}
Input: ri!limit
35
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