sUTL core library, part 3

Named reusable transforms, with full declarations and explicit dependency lists.

sUTL · Guide · Reference · Examples

These are declarations from the core distribution. Compile their named requirements against the complete distribution; an isolated declaration may depend on others. Historical language: "sUTL0" labels are retained as archived input, accepted by the current language. See declarations and libraries.

when_core_emlynoregan_com

{
  "name": "when_core_emlynoregan_com",
  "transform-t": [
    "^%",
    {
      "&": "reduce",
      "list": "^@.cases",
      "accum": {
        "found": false,
        "result": null
      },
      "t": {
        "'": {
          "&": "if",
          "cond": {
            "'": "^@.accum.found"
          },
          "true": {
            "'": "^@.accum"
          },
          "false": {
            "'": {
              "&": "if",
              "cond": {
                "'": [
                  "&&&",
                  [
                    "&=",
                    {
                      "&": "type",
                      "value": "^@.item"
                    },
                    "list"
                  ],
                  [
                    "&=",
                    {
                      "&": "len",
                      "list": "^@.item"
                    },
                    2
                  ]
                ]
              },
              "true": {
                "'": {
                  "&": "if",
                  "cond": {
                    "'": {
                      "!": {
                        "!": "^@.item.0"
                      }
                    }
                  },
                  "true": {
                    "'": {
                      "found": true,
                      "result": {
                        "!": "^@.item.1"
                      }
                    }
                  },
                  "false": {
                    "'": "^@.accum"
                  }
                }
              },
              "false": {
                "'": {
                  "found": true,
                  "result": {
                    "!": "^@.item"
                  }
                }
              }
            }
          }
        }
      }
    },
    "result"
  ]
}

isdict_core_emlynoregan_com

{
  "name": "isdict_core_emlynoregan_com",
  "transform-t": [
    "&=",
    {
      "&": "type",
      "value": "^@.item"
    },
    "map"
  ]
}

islist_core_emlynoregan_com

{
  "name": "islist_core_emlynoregan_com",
  "transform-t": [
    "&=",
    {
      "&": "type",
      "value": "^@.item"
    },
    "list"
  ]
}

issimple_core_emlynoregan_com

Requires: isdict_core, islist_core.

{
  "name": "issimple_core_emlynoregan_com",
  "transform-t": [
    "&!",
    [
      "&||",
      {
        "&": "isdict_core"
      },
      {
        "&": "islist_core"
      }
    ]
  ],
  "requires": [
    "isdict_core",
    "islist_core"
  ]
}

newdiff_core_emlynoregan_com

Requires: hasitems, isdict, islist, switch, map_core, isinlist, newdiff_core.

{
  "name": "newdiff_core_emlynoregan_com",
  "transform-t": {
    "!": {
      ":": {
        "!": {
          ":": {
            "&": "if",
            "cond": {
              ":": {
                "!": "^@.keepvalue"
              }
            },
            "true": {
              ":": "^@.value"
            }
          }
        },
        "value": {
          "&": "switch",
          "value": {
            "&": "type",
            "value": "^@.new"
          },
          "cases": [
            [
              "map",
              {
                "&": "if",
                "cond": {
                  "'": {
                    "&": "isdict",
                    "item": "^@.old"
                  }
                },
                "true": {
                  "'": {
                    "&": "makemap",
                    "value": {
                      "&": "map_core",
                      "list": {
                        "&": "keys",
                        "map": "^@.new"
                      },
                      "t": {
                        ":": {
                          "&": "if",
                          "cond": {
                            ":": {
                              "&": "isinlist",
                              "list": {
                                "&": "keys",
                                "map": "^@.old"
                              }
                            }
                          },
                          "true": {
                            "'": {
                              "&": "if",
                              "cond": {
                                ":": [
                                  "&=",
                                  [
                                    "^%",
                                    "^@.new",
                                    "^@.item"
                                  ],
                                  [
                                    "^%",
                                    "^@.old",
                                    "^@.item"
                                  ]
                                ]
                              },
                              "true": null,
                              "false": {
                                ":": {
                                  "!": {
                                    ":": {
                                      "&": "if",
                                      "cond": {
                                        ":": {
                                          "!": "^@.keepvalue"
                                        }
                                      },
                                      "true": {
                                        ":": [
                                          "^@.item",
                                          "^@.value"
                                        ]
                                      }
                                    }
                                  },
                                  "value": {
                                    "&": "newdiff_core",
                                    "old": [
                                      "^%",
                                      "^@.old",
                                      "^@.item"
                                    ],
                                    "new": [
                                      "^%",
                                      "^@.new",
                                      "^@.item"
                                    ]
                                  }
                                }
                              }
                            }
                          },
                          "false": {
                            ":": [
                              "^@.item",
                              [
                                "^%",
                                "^@.new",
                                "^@.item"
                              ]
                            ]
                          }
                        }
                      }
                    }
                  }
                },
                "false": {
                  ":": "^@.new"
                }
              }
            ],
            [
              "list",
              {
                "!": {
                  ":": {
                    "&": "if",
                    "cond": {
                      ":": {
                        "&": "hasitems"
                      }
                    },
                    "true": {
                      ":": "^@.list"
                    },
                    "false": []
                  }
                },
                "list": {
                  "&": "if",
                  "cond": {
                    "'": {
                      "&": "islist",
                      "item": "^@.old"
                    }
                  },
                  "true": {
                    "'": [
                      "^%",
                      {
                        "&": "reduce",
                        "list": "^@.new",
                        "accum": {
                          "index": 0,
                          "result": []
                        },
                        "t": {
                          ":": {
                            "index": [
                              "&+",
                              "^@.accum.index",
                              1
                            ],
                            "result": [
                              "&&",
                              "^@.accum.result",
                              [
                                {
                                  "!": {
                                    ":": {
                                      "&": "if",
                                      "cond": {
                                        ":": {
                                          "!": "^@.keepvalue"
                                        }
                                      },
                                      "true": {
                                        ":": "^@.value"
                                      }
                                    }
                                  },
                                  "value": {
                                    "&": "newdiff_core",
                                    "old": [
                                      "^%",
                                      "^@.old",
                                      "^@.accum.index"
                                    ],
                                    "new": "^@.item"
                                  }
                                }
                              ]
                            ]
                          }
                        }
                      },
                      "result"
                    ]
                  },
                  "false": {
                    ":": "^@.new"
                  }
                }
              }
            ],
            {
              "&": "if",
              "cond": {
                ":": [
                  "&=",
                  "^@.new",
                  "^@.old"
                ]
              },
              "false": {
                ":": "^@.new"
              }
            }
          ]
        }
      }
    },
    "keepvalue": {
      ":": [
        "&||",
        "^@.value",
        [
          "&!",
          {
            "&": "isinlist",
            "item": {
              "&": "type"
            },
            "list": [
              "null",
              "map",
              "list"
            ]
          }
        ]
      ]
    }
  },
  "requires": [
    "hasitems",
    "isdict",
    "islist",
    "switch",
    "map_core",
    "isinlist",
    "newdiff_core"
  ]
}

Core library contents

Source

Adapted from the sUTL source material.

Back to sUTL · Software & Agents · All topics

View page as JSON