a!localVariables(): label every seat in a venue
Medium
A venue's booking page draws its seating plan one row at a time. Given the row letters and the number of seats in every row, return one list of seat labels per row.
Rows {"A", "B"} with 3 seats give {{"A1", "A2", "A3"}, {"B1", "B2", "B3"}}.
Watch out
- Inside a nested
a!forEach(),fv!itembelongs to the inner loop. - Catch the row letter in a local before the inner loop starts, so the inner loop can still reach it.
Inputs
ri!rows— List of Textri!seats— Integer
ri! Rule Inputs
ri!rowsList of Text{
"A",
"B"
}ri!seatsInteger3
Example 1 — Two rows of three
Input: ri!rows
{
"A",
"B"
}Input: ri!seats
3
Output:
{
{"A1", "A2", "A3"},
{"B1", "B2", "B3"}
}Example 2 — One row of two
Input: ri!rows
{"C"}Input: ri!seats
2
Output:
{{"C1", "C2"}}Example 3 — Three rows of one
Input: ri!rows
{
"A",
"B",
"C"
}Input: ri!seats
1
Output:
{
{"A1"},
{"B1"},
{"C1"}
}Example 4 — No rows
Input: ri!rows
{}Input: ri!seats
4
Output:
{}Appian Expression Tips
- • Use
ri!variableNamefor 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