{"id":32179721,"url":"https://github.com/analyticbastard/macro-medley","last_synced_at":"2026-07-16T15:32:25.469Z","repository":{"id":62433514,"uuid":"94587635","full_name":"analyticbastard/macro-medley","owner":"analyticbastard","description":"Macro library for more succinct Clojure code","archived":false,"fork":false,"pushed_at":"2017-06-18T01:16:58.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-31T23:02:28.430Z","etag":null,"topics":["clojure","library","medley"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"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/analyticbastard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-16T23:13:25.000Z","updated_at":"2020-05-18T00:51:00.000Z","dependencies_parsed_at":"2022-11-01T21:01:58.046Z","dependency_job_id":null,"html_url":"https://github.com/analyticbastard/macro-medley","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/analyticbastard/macro-medley","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticbastard%2Fmacro-medley","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticbastard%2Fmacro-medley/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticbastard%2Fmacro-medley/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticbastard%2Fmacro-medley/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/analyticbastard","download_url":"https://codeload.github.com/analyticbastard/macro-medley/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticbastard%2Fmacro-medley/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35549640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-16T02:00:06.687Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clojure","library","medley"],"created_at":"2025-10-21T21:13:19.943Z","updated_at":"2026-07-16T15:32:25.464Z","avatar_url":"https://github.com/analyticbastard.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# macro-medley\n\n![macro-medley Build Status](https://circleci.com/gh/analyticbastard/macro-medley.svg?\u0026style=shield\u0026circle-token=4c2042ac8fb21debecbd6cc6fe46ddfb76f462b6 \"macro-medley Build Status\")\n\n\nMedley of utility macros for a more expressive idiomatic code\n\n[weavejester/medley](https://github.com/weavejester/medley) specifically includes only functions so macros are explicitly excluded. This library intends to provide a home for all those macros that are very useful but self-contained and small enough not to be part of their own framework or purpose library. \n\n## Usage\n\nInclude this dependency in your Leiningen or Boot project.\n\n```\n[macro-medley 0.1.0]\n```\n\nRequire the namespace as usual\n\n```clojure\n(require '[macro-medley.core :refer :all])\n```\n\nNow you can use the library macros\n\n### Self mappers (or convenient zipmap)\n\nA pattern you may have come across is this\n\n```clojure\n(zipmap [:a :b :c] [a b c])\n```\n\nwhich is needed to build a map as an input to a map destructuring function (or build the map manually). The bindings are very often named identically to the input map's keys.\n\nThis set of functions remove the redundancy of having to reapeat the binding symbol as a keyword and reduces the boilerplate.\n\n```clojure\n(let [a 1 b 2]\n  (selfmapk a))\n```\n\nyields `{:a 1}`.\n\n```clojure\n(let [a 1 b 2]\n  (selfmapk a b))\n```\n\nevaluates to `{:a 1 :b 2}`\n\nSeveral flavours provided: the map's key types can be plain key, qualified key, string and symbol. For example, when using the following command within the REPL\n\n```clojure\n(let [a 1 b 2]\n  (selfmapq a b))\n```\n\nwe would get namespace-qualified keywords as map keys `{:user/a 1 :user/b 2}`, assuming the current namespace is the default REPL namespace `user`.\n\n### Multiple-binding when-let and if-let\n\nDespite having to decide what a multiple-binding when-let or if-let has to do, if evaluating the body if all, some, the first or the last binding is not falsey, these forms are often very handing to reduce the amout of let blocks and increase the legibility and declarativeness of the code (equivalently, reduce the imperativeness).\n\n```clojure\n(when-let* [a 1\n            b 2]\n [a b])\n```\n\nwould evaluate to `[1 2]`. However\n\n```clojure\n(when-let* [a 1\n            b nil]\n [a b])\n```\n\nwould evaluate to `nil`. Similarly\n\n```clojure\n(if-let* [a 1\n            b 2]\n [a b]\n [3 4])\n```\n\nwould evaluate to `[1 2]` and\n\n```clojure\n(if-let* [a 1\n          b nil]\n [a b]\n [3 4])\n```\n\nwould yield `[3 4]`. When the else form is absent, the result is `nil` as expected.\n\n\n## Contributing\n\nRemember: never do with a macro what you can do with a function.\nIf your utility code is a function (i.e., something that processes run time data) then I suggest you open your pull request to [weavejester/medley](https://github.com/weavejester/medley)\n \nOtherwise, if your code operates with compiler data structures, such as binding names and the like, then I will be more than happy to include your utilities in the library.\n\n## License\n\nCopyright © 2017 Javier Arriero\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalyticbastard%2Fmacro-medley","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanalyticbastard%2Fmacro-medley","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalyticbastard%2Fmacro-medley/lists"}