7. Larger transformations

Reshape documents, transform real data and construct programs as values.

sUTL · Guide · Reference · Examples

The Studio examples show three useful scales of sUTL programming.

Reshaping a document

Paths embedded in a structural map are the simplest useful pattern:

{
  "person": {
    "fullname": "^$.name",
    "title": "Mr"
  },
  "address": {
    "line1": "^$.addr"
  }
}

This is analogous to a JSON template, but every value can be an arbitrary transform.

See the path-basic-2 example.

Transforming real data

The tweet example selects a screen name and text, recursively gathers several URL fields, and removes nulls through a library transform. It includes its original 2010 Twitter object as source data:

tweettransform

Constructing transforms

The sum and average examples demonstrate sUTL's Lisp-like side: a transform can construct another transform, inspect it, and evaluate it. Start with:

fixedsum

Then compare the explicit scope form:

avgrefactor1

Working with the Studio catalogue

The catalogue contains:

The expected result makes each example executable and testable. Normative language behavior remains in the conformance corpus.

Where to go next

Use sUTL where code-as-data, immutable transformations, and portable JSON-shaped programs are an advantage. For new work, keep transforms small, test them against explicit source/result examples, use !! for higher-order scope, and compile named dependencies rather than relying on ambient libraries.

Next: Historical dialects and implementations.

Continue learning

Previous: 6. Declarations and libraries · Guide contents · Language reference

Source

Adapted from the sUTL source material.

Back to sUTL · Software & Agents · All topics

View page as JSON