andAncestors()

Returns the ancestors of the specified entry and the entry itself.

Details

This function will return all of the "ancestor" entries of the specified entry (or entries), as well as the entry itself.

Ancestors are defined as any entries that can be reached by following "IS A" relationships. For example, if Orca is an Oceanic dolphin, and Oceanic dolphin is a Mammal, then the ancestors of Orca are Oceanic dolphin and Mammal.

The result will include an annotation for "distance", which indicates how many "IS A" relationships there are between the original entry and the ancestor (see examples below). By default, the resulting ancestors will be sorted by distance, with the closest ancestors first.

Arguments

First argument: an Entry or a set of Entries, whose ancestors we want to retrieve.

Examples

  1. A specific entry and its ancestors:
    entry("demo-orca").andAncestors()
    Result:

  2. A specific entry, and its ancestors, displaying their "distance" from the original entry:
    entry("demo-orca").andAncestors().map(apply=(entry -> entry.annotate(detail=entry.distance)))
    Result:

  3. The current entry and its ancestors:
    this.andAncestors() [1]

  4. Ancestors of a multiple entries:
    [entry("demo-orca"), entry("demo-elk")].andAncestors()
    The elk is a type of Deer, and the orca is a type of Oceanic dolphin, and both are mammals, so this gives:

© Copyright 2022 MacDonald Thoughtstuff Inc. All documentation text and multimedia on this site are licensed under the CC BY-SA 4.0 license.