sUTL core library, part 2

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.

quicksort_core_emlynoregan_com

Requires: quicksort_core_emlynoregan_com, qsfilter_core_emlynoregan_com.

{
  "language": "sUTL0",
  "name": "quicksort_core_emlynoregan_com",
  "transform-t": {
    "&": "if",
    "cond": {
      "'": "^@.list"
    },
    "true": {
      "'": [
        "&&",
        {
          "!": "^*.quicksort_core_emlynoregan_com",
          "list": {
            "!": "^*.qsfilter_core_emlynoregan_com",
            "list": "^@.list",
            "left": true,
            "sortkey": "^@.sortkey"
          }
        },
        [
          {
            "&": "head",
            "b": "^@.list"
          }
        ],
        {
          "!": "^*.quicksort_core_emlynoregan_com",
          "list": {
            "!": "^*.qsfilter_core_emlynoregan_com",
            "list": "^@.list",
            "left": false,
            "sortkey": "^@.sortkey"
          }
        }
      ]
    },
    "false": []
  },
  "requires": [
    "quicksort_core_emlynoregan_com",
    "qsfilter_core_emlynoregan_com"
  ]
}

qsfilter_core_emlynoregan_com

Requires: filter_core_emlynoregan_com.

{
  "language": "sUTL0",
  "name": "qsfilter_core_emlynoregan_com",
  "transform-t": {
    "!": "^*.filter_core_emlynoregan_com",
    "list": {
      "&": "tail",
      "b": "^@.list"
    },
    "head": {
      "&": "head",
      "b": "^@.list"
    },
    "filter-t": {
      "'": {
        "!": [
          {
            "&": "if",
            "cond": {
              "'": "^@.left"
            },
            "true": {
              "'": {
                "'": "&<"
              }
            },
            "false": {
              "'": {
                "'": "&>="
              }
            }
          },
          {
            "!": [
              "&&",
              {
                "'": "^%"
              },
              [
                "^@.item"
              ],
              "^@.keypath"
            ]
          },
          {
            "!": [
              "&&",
              {
                "'": "^%"
              },
              [
                "^@.head"
              ],
              "^@.keypath"
            ]
          }
        ]
      }
    }
  },
  "requires": [
    "filter_core_emlynoregan_com"
  ]
}

idlisttomap_core_emlynoregan_com

Requires: map_core_emlynoregan_com.

{
  "name": "idlisttomap_core_emlynoregan_com",
  "transform-t": {
    "&": "makemap",
    "value": {
      "!": "^*.map_core_emlynoregan_com",
      "list": "^@.list",
      "t": {
        "'": [
          {
            "!": [
              "&&",
              {
                "'": "^%"
              },
              [
                "^@.item"
              ],
              "^@.keypath"
            ]
          },
          "^@.item"
        ]
      }
    }
  },
  "requires": [
    "map_core_emlynoregan_com"
  ]
}

join_core_emlynoregan_com

{
  "name": "join_core_emlynoregan_com",
  "transform-t": [
    "^%",
    {
      "!": {
        "'": {
          "&": "if",
          "cond": {
            "'": "^@.list"
          },
          "false": null,
          "true": {
            "'": {
              "&": "reduce",
              "list": "^@.list",
              "accum": {
                "index": 0,
                "result": ""
              },
              "t": {
                "'": {
                  "&": "if",
                  "cond": {
                    "'": [
                      "&=",
                      "^@.accum.index",
                      0
                    ]
                  },
                  "true": {
                    "'": {
                      "index": 1,
                      "result": "^@.item"
                    }
                  },
                  "false": {
                    "'": {
                      "&": "if",
                      "cond": {
                        "'": [
                          "&=",
                          "^@.listlen",
                          [
                            "&+",
                            "^@.accum.index",
                            1
                          ]
                        ]
                      },
                      "true": {
                        "'": {
                          "index": [
                            "&+",
                            "^@.accum.index",
                            1
                          ],
                          "result": [
                            "&+",
                            "^@.accum.result",
                            "^@.lastseparator",
                            "^@.item"
                          ]
                        }
                      },
                      "false": {
                        "'": {
                          "index": [
                            "&+",
                            "^@.accum.index",
                            1
                          ],
                          "result": [
                            "&+",
                            "^@.accum.result",
                            "^@.separator",
                            "^@.item"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "separator": {
        "&": "if",
        "cond": {
          "'": "^@.separator"
        },
        "true": {
          "'": "^@.separator"
        },
        "false": ", "
      },
      "lastseparator": {
        "&": "if",
        "cond": {
          "'": "^@.lastseparator"
        },
        "true": {
          "'": "^@.lastseparator"
        },
        "false": {
          "'": {
            "&": "if",
            "cond": {
              "'": "^@.separator"
            },
            "true": {
              "'": "^@.separator"
            },
            "false": " and "
          }
        }
      },
      "listlen": {
        "&": "len",
        "list": "^@.list"
      }
    },
    "result"
  ]
}

slice_core_emlynoregan_com

{
  "name": "slice_core_emlynoregan_com",
  "transform-t": {
    "!": {
      "'": {
        "!": {
          "'": [
            "^%",
            {
              "&": "reduce",
              "list": "^@.list",
              "accum": {
                "index": 0,
                "result": []
              },
              "t": {
                "'": {
                  "&": "if",
                  "cond": {
                    "'": [
                      "&&&",
                      [
                        "&>=",
                        "^@.accum.index",
                        "^@.start"
                      ],
                      [
                        "&<",
                        "^@.accum.index",
                        "^@.stop"
                      ]
                    ]
                  },
                  "true": {
                    "'": {
                      "index": [
                        "&+",
                        "^@.accum.index",
                        1
                      ],
                      "result": [
                        "&&",
                        "^@.accum.result",
                        "^@.item"
                      ]
                    }
                  },
                  "false": {
                    "'": {
                      "index": [
                        "&+",
                        "^@.accum.index",
                        1
                      ],
                      "result": "^@.accum.result"
                    }
                  }
                }
              }
            },
            "result"
          ]
        },
        "start": {
          "!": "^@.fixarg",
          "arg": "^@.start",
          "defaultarg": 0
        },
        "stop": {
          "!": "^@.fixarg",
          "arg": "^@.stop",
          "defaultarg": {
            "&": "len",
            "list": "^@.list"
          }
        }
      }
    },
    "fixarg": {
      "'": {
        "&": "if",
        "cond": {
          "'": "^@.arg"
        },
        "true": {
          "'": {
            "&": "if",
            "cond": {
              "'": [
                "&<",
                "^@.arg",
                0
              ]
            },
            "true": {
              "'": [
                "&+",
                {
                  "&": "len",
                  "list": "^@.list"
                },
                "^@.arg"
              ]
            },
            "false": {
              "'": "^@.arg"
            }
          }
        },
        "false": "^@.defaultarg"
      }
    }
  }
}

coalesce_core_emlynoregan_com

{
  "language": "sUTL0",
  "name": "coalesce_core_emlynoregan_com",
  "transform-t": {
    "&": "reduce",
    "list": "^@.list",
    "accum": null,
    "t": {
      "'": {
        "&": "if",
        "cond": {
          "'": [
            "&!=",
            "^@.accum",
            null
          ]
        },
        "true": {
          "'": "^@.accum"
        },
        "false": {
          "'": "^@.item"
        }
      }
    }
  }
}

switch_core_emlynoregan_com

Requires: isinlist.

{
  "name": "switch_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": {
                    "'": [
                      "&=",
                      {
                        "&": "type",
                        "value": "^@.item.0"
                      },
                      "list"
                    ]
                  },
                  "true": {
                    "'": {
                      "&": "if",
                      "cond": {
                        "'": {
                          "!": "^*.isinlist",
                          "list": "^@.item.0",
                          "item": "^@.value"
                        }
                      },
                      "true": {
                        "'": {
                          "found": true,
                          "result": "^@.item.1"
                        }
                      },
                      "false": {
                        "'": "^@.accum"
                      }
                    }
                  },
                  "false": {
                    "'": {
                      "&": "if",
                      "cond": {
                        "'": [
                          "&=",
                          "^@.item.0",
                          "^@.value"
                        ]
                      },
                      "true": {
                        "'": {
                          "found": true,
                          "result": "^@.item.1"
                        }
                      },
                      "false": {
                        "'": "^@.accum"
                      }
                    }
                  }
                }
              },
              "false": {
                "'": {
                  "found": true,
                  "result": "^@.item"
                }
              }
            }
          }
        }
      }
    },
    "result"
  ],
  "requires": [
    "isinlist"
  ]
}

Core library contents

Source

Adapted from the sUTL source material.

Back to sUTL · Software & Agents · All topics

View page as JSON