{"id":32181077,"url":"https://github.com/clojureman/tldr","last_synced_at":"2026-07-03T21:33:59.437Z","repository":{"id":62434946,"uuid":"208155704","full_name":"clojureman/tldr","owner":"clojureman","description":"More than a let by another name","archived":false,"fork":false,"pushed_at":"2020-09-22T20:34:01.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T22:32:14.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clojureman.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":"2019-09-12T22:20:10.000Z","updated_at":"2023-07-17T06:01:24.000Z","dependencies_parsed_at":"2022-11-01T21:02:21.073Z","dependency_job_id":null,"html_url":"https://github.com/clojureman/tldr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clojureman/tldr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojureman%2Ftldr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojureman%2Ftldr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojureman%2Ftldr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojureman%2Ftldr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clojureman","download_url":"https://codeload.github.com/clojureman/tldr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojureman%2Ftldr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35102737,"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-03T02:00:05.635Z","response_time":110,"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":[],"created_at":"2025-10-21T22:28:41.014Z","updated_at":"2026-07-03T21:33:59.431Z","avatar_url":"https://github.com/clojureman.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TL;DR\n\u003e The Essence Comes First \n\n[![Clojars Project](https://img.shields.io/clojars/v/tldr.svg)](https://clojars.org/tldr) Beta\n```clojure\n(require '[tldr.core :refer :all])\n\n(function -main [] \n\n          (println 'Hello something)\n          \n          where   \n               something \"world!\") \n```\n\nThis Clojure library enables a coding style where the most important ideas are expressed first. \n\nDetails come later, and can be read as needed.\n\nThis is important because code is *read* more often than it is *written*. \n\n## Reads Like a Press Release\n\nCode can be read like a press release - only the first few lines matter; the rest is optional.\n\n```clojure\n(compute\n    {:top-students \n          (take 3 (reverse students-by-grade))\n     :avg-grade \n          (/ (sum student-grades)\n             (count student-grades))}\n where\n    sum (partial apply +)\n    students-by-grade (sort-by :grade students)\n    student-grades (map :grade students)\n \n where\n    students '[{:name Peterson  :grade 8}\n               {:name Zeus      :grade 100}\n               {:name Zach      :grade 20}\n               {:name Sleepy    :grade 0}\n               {:name Droopy    :grade 7}]\n)\n```\nEach added section provides you with more details if you care to read that far.\n\n\nIn terms of implementation `compute` is a macro, and `where` is just syntax.\n\n### Example: The Quadratic Equation\n```clojure\n;; Find the solutions to the quadratic equation\n;;     a*x^2 + b*x + c == 0\n;; (Just like in school)\n\n(compute\n    (distinct solutions)\n where\n    solutions (map \n                main-formula \n                (when D [D (- D)]))\n where\n    main-formula #(/ (- % b) 2 a)\n    D (try (Math/sqrt (- (* b b) (* 4 a c)))\n           (catch Throwable _ nil))   \n)\n```\n\nIf you think it looks better, you can use two or more dashes instead of `where`.\n\nThe above example is equivlent to \n```clojure\n(compute \n    (distinct solutions)\n    ----------------------------------------\n    solutions (map \n                main-formula \n                (when D [D (- D)]))\n    ----------------------------------------\n    main-formula #(/ (- % b) 2 a)\n    D (try (Math/sqrt (- (* b b) (* 4 a c)))\n           (catch Throwable _ nil)))\n```\n## Brain Protection\n*The better your brain, the more you need it*\n\n- Visual Guard Rails\n  \u003e The lines give you a visual indication of what code to waste your precious brain cycles on.\n- Independent bindings\n  \n  All bindings within a `where` block are independent (sometimes called \"parallel\") and do not know of each other. \n\n  \u003e You can be assured that *the order of bindings within a `where` block does not matter*.\n\n  (Except if you bind the same name more than once in a block - in which case the last one wins. \n  Future releases are expected to contain some level of protection against this).\n\n- Limited Visibility\n\n  A name bound in a `where` block is *only* visible in the code block immediately preceeding it. This is a *good thing*, because\n\n  \u003e The less code you have to read in order to understand any given piece of a program, the better your chances are of succeeding. \n\n## But Wait ... There's More\n\n### Nested functions \n***Question:*** *How do you know if an inner function closes over the arguments of an outer function?*\n\n***Answer:*** *You don't* - unless you carefully read the source code of the inner function. You may also have to read other functions and expressions inside the outer function but outside the inner one to be sure. \n\nThis is one of the reasons there is no bestseller named *\"The Joy of Reading Long Clojure Functions Written by Other People\"*.\n\nIt is customary for Clojure programs to contain a lot\nof separate source files with very little code in each, and with a lot of functions that are used only \nlocally and within the namespaces in which they are defined. And often only once! Just a few functions are used outside the namespace in which they are defined.\n\nClearly some kind of grouping other than the namespace could be useful.\n\nSay hello to `function`\n```clojure\n(function print-labels [club-members]  \n    (doseq [member club-members]\n       (print-one (format-label member)))\n    --------------------------------------------------\n    print-one    (fn [label] .....)\n    format-label (juxt :firstname :lastname :room))\n```\nThe above code is a lot like \n```clojure\n(defn print-labels [club-members]\n   (let [print-one    (fn [label] .....)\n         format-label (juxt :firstname :lastname :room)]\n      (doseq [member club-members]\n         (print-one (format-label member)))))\n```\nbut there is one important difference: We know at a glance that the code after `-----------------`  defines two independent functions that do not close over each other or anything in the function body or the function arguments.\n\nThis also means that we can later refactor the code by moving for instance `print-one` function outside as `(defn print-one [label] ...)` without risk of breaking anything. \n\n### Of Course There's Some More Sugar\n\nInstead of binding a name to a function in a `where` block, like for instance `f (fn [x y] ...)`\nwe can simply write `(function f [x y])`.\nIn the label example it would be\n\n```clojure\n(function print-labels [club-members]  \n    (doseq [member club-members]\n       (print-one (format-label member)))\n    --------------------------------------------------\n    (function print-one [label] \n        .....)\n    format-label (juxt :firstname :lastname :room))\n```\n### Mutually Recursive Functions\n\nSometimes we absolutely need local functions to call each other in a criss cross pattern. Clojure has `letfn` for this, and we have some sugar for that:\n```clojure\n(compute\n    (f \"x\")\n  where-mutual\n    (function f [x] (if (\u003c 10 (count x))\n                       x\n                       (g (str \"-\" x))))\n    (function g [s] (if (\u003c 10 (count s))\n                       s\n                       (f (str \"|\" s)))))\n```\nYou can even go a bit crazy and use anonymous functions in a `where-mutual` block\n```clojure\n(compute\n    (f \"x\")\n  where-mutual\n    f #(if (\u003c 10 (count %))\n           %\n           (g (str \"-\" %)))\n    g (fn [s] (if (\u003c 10 (count s))\n                   s\n                   (f (str \"|\" s)))))\n```\nYou can also use higher order functions like `comp` or `juxt` to define\nindividual functions that can call each other mutually. \n```clojure\n(compute\n         (f {:name \"Alfie\" :age 21 :occupation \"unknown\" \n             :address {:street \"Main Street\" :number 1203}}) \n where-mutual\n         f (comp println (partial record \"\"))\n         record #(str \"RECORD\\n\"\n                      (apply str (map field (repeat (str % \"  \")) %2))\n                      % \"END;\\n\")\n         (function field [indent [fieldname value]]\n                   (str indent\n                        (name fieldname)\n                        \" = \"\n                        (if (map? value)\n                          (record (field-indent indent (name fieldname)) value)\n                          (str (pr-str value) \";\\n\"))))\n where\n         (function field-indent [indent fieldname]\n                   (apply str indent\n                          (repeat\n                            (+ 3 (count (name fieldname)))\n                            \" \"))))\n\n;; The above code results in this being printed to stdout:\n\nRECORD\n  name = \"Alfie\";\n  age = 21;\n  occupation = \"unknown\";\n  address = RECORD\n              street = \"Main Street\";\n              number = 1203;\n            END;\nEND;\n```\n\n## Use in Clojure, ClojureScript, or both\nTo use from Clojure you need to require\n```clojure\n[tldr.core :refer :all]\n```\nTo use from ClojureScript you need to require\n```clojure\n[tldr.core :refer-macros :all]\n```\nIf you want your code to compile in both Clojure and ClojureScript you will have to require\n```clojure\n[tldr.core :refer-macros :all :refer :all]\n```\n\n\n## License\n\nCopyright © 2019 Mads Olsen\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published by\nthe Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojureman%2Ftldr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclojureman%2Ftldr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojureman%2Ftldr/lists"}