3/5

enumerate(): project a loyalty balance visit by visit

Medium

A café app shows a customer how their loyalty balance will grow. Starting from ri!current points and earning ri!perVisit points on each visit, return the balance after each of the next ri!visits visits.

40 points, 15 per visit and 3 visits gives {55, 70, 85}.

Watch out

  • The first figure is the balance after one visit, not before any.
  • No loop is needed: adding and multiplying both apply themselves to the whole list.

Inputs

  • ri!current — Integer
  • ri!perVisit — Integer
  • ri!visits — Integer

ri! Rule Inputs

ri!currentInteger
40
ri!perVisitInteger
15
ri!visitsInteger
3

Example 1 — Three visits

Input: ri!current
40
Input: ri!perVisit
15
Input: ri!visits
3
Output:
{
  55,
  70,
  85
}

Example 2 — A brand-new member

Input: ri!current
0
Input: ri!perVisit
10
Input: ri!visits
2
Output:
{
  10,
  20
}

Example 3 — A single visit

Input: ri!current
95
Input: ri!perVisit
5
Input: ri!visits
1
Output:
{100}

Example 4 — No visits planned

Input: ri!current
40
Input: ri!perVisit
15
Input: ri!visits
0
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