docs← Back to article

Markdown for LLMs

nb-04 solutions — The permit fee

The source Markdown for this article. Copy it into your assistant or download it as a text file.

Download this articlePlain text ↗
# nb-04 solutions — The permit fee

*Checkable against `law test packs/examples/language-demo/calculations`
(9 checked, 9 passed). Identifiers and code as written.*

## 1. `TieredRate(12)` — value and which row?

**Answer: `0.2`, the second row (`when months >= 12 => 0.2`).**

Only the second row's guard holds (`12 >= 24` is false, `12 >= 12` is
true), so `hit first` takes it. `otherwise` is not reached because a
guarded row matched.

## 2. `PriorityRate(12)` — value and which row?

**Answer: `0.2`, the first-listed row (`when months >= 12 => 0.2`).**

Again only one guarded row matches (`12 >= 24` is false), so row order
and priority order agree here: the matched value `0.2` is the only
candidate, and it is in the priority list.

## 3. `PriorityRate(30)` — value? What if row order decided?

**Answer: `0.5`. Under row order it would be `0.2`.**

Both guarded rows match for 30 months. The priority list
`0.5, 0.2, 0.0` ranks the matched values, so `0.5` wins — confirmed by
the test `priority selects by list, not by rows`, which expects
`value == 0.5`. If selection followed table text order, the `0.2` row
stands first and the answer would be `0.2`. The test distinguishes the
two semantics, and priority wins.

## 4. `MatchedCount(18)` — value, and what does it say?

**Answer: `2`. Two rows matched.**

`MatchedCount` uses `hit collect aggregate count` with guards
`months >= 24`, `months >= 12`, `months >= 6`. For 18 months the last
two hold, so the count is `2`. It tells you the *number* of matching
rows — the direct observation of "which (and how many) rows fired",
as opposed to `hit first`, which silently discards all but one.

## How to verify

```sh
law test packs/examples/language-demo/calculations
```

Expected: `итого: 9 проверено, 9 прошли, 0 не прошли, 0 не исполнены`.
The deciding tests are `first takes the first matching row`
(`TieredRate(30) == 0.5`), `count of matching rows`
(`MatchedCount(18) == 2`), and `priority selects by list, not by rows`
(`PriorityRate(30) == 0.5`).