Explorer

core.eval-find-last-by-field

description
The evaluator's list_find_last_by_field (core.eval-builtin-call): the last record value in items, from index down to 0, whose field equals value, as an option value
type
Fn(items: List<@core.value>, field: String, value: @core.value, index: Number) -> @core.value
expression
fn(items$0, field$1, value$2, index$3) =>
  match @core.list-get(list: $0, index: $3) {
    #none(_) =>
      #variant({tag: "none", payload: #unit}),
    #some(item$4) =>
      match $4 {
        #record(fields$5) =>
          match @core.value-equals(val_a: @core.record-field-lookup(items: $5, key: $1, index: 0), val_b: $2) {
            true =>
              #variant({tag: "some", payload: $4}),
            false =>
              @core.eval-find-last-by-field(items: $0, field: $1, value: $2, index: @core.minus(left: $3, right: 1))
          },
        _ =>
          @core.eval-find-last-by-field(items: $0, field: $1, value: $2, index: @core.minus(left: $3, right: 1))
      }
  }
visibility
public
core.eval-find-last-by-field (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: crrYiXiw6oLrxUMSsyELuyOfXpeMqVFCBhc7asPtNAQ
content hash: pYPe3B3iD9Cg_nN4d-nlZL4lTwawSd7nNxYYO-DQ_ik