Skip to content

Interlude.Compute.Lookup

In Depth

Compute.Lookup(key, lookupKeys, lookupValues, fallback: null)

Maps a field's answer through a lookup table. The keys are matched against the answer's text form.

The inputs are:

  • key (string) — The field to read.
  • lookupKeys (list of object) — The values to match.
  • lookupValues (list of object) — What each match produces.
  • fallback (object, defaults to null) — What to produce when nothing matches.

Returns computation — The computation.

Search terms: lookup, map, translate, dictionary, switch.


About the Compute nodes

Values worked out from other answers, for use with Behavior.WithComputed.

A computed field is driven by the form rather than by the user: it recalculates whenever anything it reads changes, in dependency order, so a total built on a subtotal is always consistent. Computed values that depend on each other in a loop are rejected when the form is built, before a window appears.


Example File

An example graph ships beside this page: Interlude.Compute.Lookup.dyn

Compute.Lookup

The form it builds:

Compute.Lookup form