{"id":13761662,"url":"https://github.com/clojure/algo.generic","last_synced_at":"2025-04-05T16:08:05.083Z","repository":{"id":57739103,"uuid":"1640035","full_name":"clojure/algo.generic","owner":"clojure","description":"Generic versions of commonly used functions, implemented as multimethods that can be implemented for any data type","archived":false,"fork":false,"pushed_at":"2024-05-07T03:58:12.000Z","size":147,"stargazers_count":95,"open_issues_count":0,"forks_count":20,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-29T15:05:23.816Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://clojure.org","language":"Clojure","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clojure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-20T11:29:10.000Z","updated_at":"2024-10-10T10:02:46.000Z","dependencies_parsed_at":"2024-01-15T03:58:30.464Z","dependency_job_id":"3105b628-2b97-4058-99f4-e26ea3e50428","html_url":"https://github.com/clojure/algo.generic","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Falgo.generic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Falgo.generic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Falgo.generic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Falgo.generic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clojure","download_url":"https://codeload.github.com/clojure/algo.generic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361689,"owners_count":20926643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T14:00:21.615Z","updated_at":"2025-04-05T16:08:05.049Z","avatar_url":"https://github.com/clojure.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# algo.generic\n\nGeneric versions of commonly used functions, implemented as multimethods\nthat can be implemented for any data type.\n\n## Usage\n\nEach submodule of clojure.algo.generic defines a set of related\nmultimethods that have the same names as their type-specific\ncounterparts in clojure.core. Implementations for standard Clojure\ndata types are provided and behave identically to the clojure.core\nversions.\n\n### Arities\n\nArithmetic and comparison functions are defined for the same arities\nthat the corresponding clojure.core functions support.  Arities higher\nthan 2 are reduced to unary and binary calls. To provide a multimethod\nimplementation for binary calls with a given pair of types, use\n`[type1 type2]` as the dispatch value. For a unary call, the dispatch\nvalue is `type` as usual. Note that `[type1 type2]` is different from\n`[type2 type1]` (in most cases you will want to provide both) and that\n`[type type]` (binary operation with both arguments of the same type)\nis different from `type` (unary operation).\n\n### Root type\n\nThis section applies only to binary operations dispatching on type\npairs, and only for types that are *not* Java classes. Types\ncreated by `deftype` and `defrecord` are Java classes, meaning that\nmost Clojure programmers can go on with the next section.\n\nOne difficulty with binary operations is that there is no predefined\nway to provide a default implementation. For single dispatch there is\n`:default`, but there is nothing equivalent to `[:default :default]`.\nThe algo.generic library therefore defines a *root type*, accessible\nas `clojure.algo.generic/root-type`, which is used in the default\nimplementations of binary operations. To integrate your own type into\nthis system, you must add the clause `(derive my-type\nclojure.algo.generic/root-type)` after your type definition. This is\nnot required for Java classes because `java.lang.Object` is\nalready derived from `root-type`.\n\n### Submodules\n\n* **algo.generic.arithmetic** provides generic `+` `-` `*` `/` for all\n  the arities that the corresponding clojure.core functions support.\n  The minimal implementations required for full arithmetic on a given\n  type is binary `+` and `*` and unary `-` and `/`. You may wish to\n  provide explicit implementations for binary `-` and `/` for\n  efficiency, otherwise the default implementations are `(- a b) =\u003e (+ a (- b))`\n   and `(/ a b) =\u003e (* a (/ b))`.\n\n* **algo.generic.collection** provides generic versions of `assoc`,\n  `dissoc`, `get`, `conj`, `empty`, `into`, and `seq`. `into` has a\n  default implementation in terms of `conj` and `seq`, but you may\n  wish to provide a more efficient one for your types.\n\n* **algo.generic.comparison** provides the comparison and test\n  functions `=`, `not=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`, `zero?`, `pos?`,\n  `neg?`, `min`, and ` max`. `not=`, `min`, and `max` cannot be\n  redefined, they are standard functions that are implemented in\n  terms of the generic functions of the module. A minimal\n  implementation of the binary comparison functions consists of\n  `=` and `\u003e`. Default implementations for `\u003c`, `\u003c=`, and `\u003e=`\n  call `\u003e`, but more efficient implementations can be provided.\n\n* **algo.generic.functor** provides a generic mapping operation\n  called `fmap`.\n\n* **algo.generic.math-functions** provides generic versions of the\n  common math functions from `java.lang.Math`, plus `sgn`, `sqr`, and\n  `conjugate`.\n\n\n## Releases and dependency information\n\nLatest stable release: 0.1.3\n\n* [All released versions](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22algo.generic%22)\n\n* [Development Snapshot Versions](https://oss.sonatype.org/index.html#nexus-search;gav~org.clojure~algo.generic~~~)\n\n[CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information:\n```clojure\norg.clojure/algo.generic {:mvn/version \"0.1.3\"}\n```\n\n[Leiningen](https://github.com/technomancy/leiningen/) dependency information:\n\n    [org.clojure/algo.generic \"0.1.3\"]\n\n[Maven](https://maven.apache.org/) dependency information:\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eorg.clojure\u003c/groupId\u003e\n      \u003cartifactId\u003ealgo.generic\u003c/artifactId\u003e\n      \u003cversion\u003e0.1.3\u003c/version\u003e\n    \u003c/dependency\u003e\n\n## License\n\nCopyright (c) Rich Hickey and contributors. All rights reserved.\n\nThe use and distribution terms for this software are covered by the\nEclipse Public License 1.0 (https://opensource.org/license/epl-1-0/)\nwhich can be found in the file epl.html at the root of this distribution.\nBy using this software in any fashion, you are agreeing to be bound by\nthe terms of this license.\nYou must not remove this notice, or any other, from this software.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Falgo.generic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclojure%2Falgo.generic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Falgo.generic/lists"}