Explorer

definy.closure-new-ids

description
The ids that are not in selected, without repeats (the first of the same ids, in the order of ids). With a few ids (8 or less, as in each step of definy.latest-closure) it compares with selected one by one, since making a hash index of selected costs more than that
type
Fn(ids: List<String>, selected: List<String>) -> List<String>
expression
fn(ids$0, selected$1) =>
  match @core.less-than(left: @core.list-length(value: $0), right: 9) {
    true =>
      @core.list-fold(
        T: String,
        A: List<String>,
        reducer: fn(acc$5, item$6) =>
          match @core.or(
              left: @definy.strings-contain(items: $1, value: $6, index: 0),
              right: @definy.strings-contain(items: $5, value: $6, index: 0)
            ) {
            true =>
              $5,
            false =>
              @core.list-append(list: $5, item: $6)
          },
        init: [],
        xs: $0
      ),
    false =>
      let selected_set$2 = @core.string-set(items: $1);
      @definy.strings-unique(
        items: @core.list-fold(
          T: String,
          A: List<String>,
          reducer: fn(acc$3, item$4) =>
            match @core.string-set-has(set: $2, value: $4) {
              true =>
                $3,
              false =>
                @core.list-append(list: $3, item: $4)
            },
          init: [],
          xs: $0
        )
      )
  }
visibility
public
definy.closure-new-ids (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: 9k5LIwCMCPguOXBGzx_5E-8GL-ndhlXX0Vl3sRPhnas
content hash: 6E8SJhCR2p2i1NnSByYXhXlh17XzMZRiQgKedwsiPas