Explorer

core.compile-reachable-ids-from

description
found with the ids of frontier and of the parts they reference (core.compile-part-references, following the references through index, a core.list-hash-index of the parts by id), breadth first like core.quote-part-ids-from
type
Fn(
  frontier: List<String>,
  found: List<String>,
  index: List<List<Record{id: String, expression: @core.expression}>>
) -> List<String>
expression
fn(frontier$0, found$1, index$2) =>
  let step$3 = @core.list-fold(
      T: String,
      A: Record{found: List<String>, next: List<String>},
      reducer: fn(acc$4, item$5) =>
        match @core.list-contains-string(list: $4.found, target: $5, index: 0) {
          true =>
            $4,
          false =>
            {
              found: @core.list-append(list: $4.found, item: $5),
              next: match @core.list-hash-index-find(index: $2, field: "id", value: $5) {
                #some(part$6) =>
                  @core.compile-part-references(expr: $6.expression, ids: $4.next),
                #none(_) =>
                  $4.next
              }
            }
        },
      init: {found: $1, next: []},
      xs: $0
    );
  match @core.equal(left: @core.list-length(value: $3.next), right: 0) {
    true =>
      $3.found,
    false =>
      @core.compile-reachable-ids-from(frontier: $3.next, found: $3.found, index: $2)
  }
visibility
public
core.compile-reachable-ids-from (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: c9nXuRTlIXaDjTZyOvRckPO3j3vS1FCIoDXSKaHR7sY
content hash: jcWCaN-1muQM-2ZF8BigvNDegVYei8gazp4BAK47zwM