{"id":13648426,"url":"https://github.com/dirkschumacher/llr","last_synced_at":"2025-05-15T10:33:16.506Z","repository":{"id":22550735,"uuid":"96664548","full_name":"dirkschumacher/llr","owner":"dirkschumacher","description":"Lisp-like-R: A clojure inspired lisp that compiles to R in R","archived":false,"fork":false,"pushed_at":"2021-12-03T13:42:07.000Z","size":83,"stargazers_count":202,"open_issues_count":17,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-12T02:07:33.860Z","etag":null,"topics":["language","lisp","lisp-dialect","r"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirkschumacher.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-09T05:59:17.000Z","updated_at":"2024-08-22T10:37:24.000Z","dependencies_parsed_at":"2022-07-27T03:02:11.396Z","dependency_job_id":null,"html_url":"https://github.com/dirkschumacher/llr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Fllr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Fllr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Fllr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Fllr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirkschumacher","download_url":"https://codeload.github.com/dirkschumacher/llr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254323270,"owners_count":22051748,"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":["language","lisp","lisp-dialect","r"],"created_at":"2024-08-02T01:04:14.659Z","updated_at":"2025-05-15T10:33:16.118Z","avatar_url":"https://github.com/dirkschumacher.png","language":"R","funding_links":[],"categories":["R","Languages"],"sub_categories":["R"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nknitr::knit_engines$set(\n  clojure = llr::knitr_language_engine()\n)\n```\n\n# llr\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nllr is a small, work in progress and just for fun clojure-like lisp on top of R's abstract syntax trees. Expressions are not interpreted, but are translated to R's AST and then interpreted by the R interpreter.\n\nMost implementation details are sub-optimal, but the focus is on having fun and producing results instead writing perfect code. There are also many bugs and inconsistencies!\n\n## Installation\n\n``` r\nremotes::install_github(\"dirkschumacher/llr\")\n```\n\n## Intro\n\n```{clojure}\n(-\u003e\n  r/datasets::mtcars\n  (r/dplyr::filter (r/base::`\u003e` hp 100))\n  (r/dplyr::summarise :count (r/dplyr::n) :mean_mpg (r/mean mpg))\n  (r/tibble::as_tibble))\n```\n\nOr run it from R\n\n```{r}\nlibrary(llr)\ninterp \u003c- llr_env$new()\ninterp$eval(\"(+ 1 1)\")\n```\n\nAlso see some [Advent Of Code solutions](https://github.com/dirkschumacher/aoc2020) in llr.\n\n### REPL\n\nIt also has a (limited) REPL\n\n```{r, eval=FALSE}\ninterp \u003c- llr_env$new()\ninterp$repl()\n```\n\n\n## Special forms\n\n### Data Types\n\n#### Lists\n\n```{clojure}\n; this is a list\n'(1 2 3 4 5 6)\n; an unquoted list is a function call\n(+ 1 2 3 4 5 6)\n```\n\n#### Vectors\n\n```{clojure}\n[1 2 3 4]\n```\n\n#### Maps\n\n```{clojure}\n{:a 1 :b 2}\n```\n\n\n### Symbols\n\n```{clojure, eval = FALSE}\nx\n```\n\n```{clojure, eval = FALSE}\nnamespaced.variable/x\n```\n\n```{clojure, eval = FALSE}\n:keyword\n```\n\n```{clojure, eval = FALSE}\n\"character\"\n```\n\n```{clojure, eval = FALSE}\n10 ; integer\n```\n\n```{clojure, eval = FALSE}\n10.42 ; double\n```\n\n### Functions\n\n```{clojure, eval = FALSE}\n(fn [a b] (+ a b))\n\n(fn this\n  ([] 0)\n  ([a] a)\n  ([a b] (+ a b))\n  ([a b \u0026 more] (reduce + (concat [a b] more))))\n```\n\n### def\n\n`def` defines a symbol in a namespace and assignes it a name.\n\n```{clojure}\n(def x 1)\n(def plus (fn [a b] (+ a b)))\n(plus x x)\n```\n\n\n### Meta-data\n\nSymbols and values can hold meta-data. That meta-data needs to be a map at the moment.\n\n```{clojure}\n(def ^{:const true} x ^{:meta \"hello\"} [ 1 2 3])\n(meta x)\n```\n\nMeta-data on symbols is currently only available to the reader.\n\n### Macros\n\nMacros are also supported. Macros are functions bound to a name with meta data `{:macro true}`.\n\nIn a macro you can use syntax-quote `\u003cbacktick\u003e` together with the unquote `~` and unquote-splice `~@` operators.\n\n```{clojure}\n(defmacro infix [operand1 operator operand2]\n  `(~operator ~operand1 ~operand2))\n(infix 1 + 1)\n```\n\n\n### Recursion\n\nSimilar to Clojure llr uses `recur` to jump to a recursion point currently only defined by `loop`.\n\n```{clojure}\n(def is-even \n  (fn [number] \n    (loop [cnt number]\n      (if (zero? cnt)\n        true\n        (if (\u003c cnt 0) false (recur (- cnt 2)))))))\n```\n\n```{clojure}\n(is-even 5001)\n```\n\n```{clojure}\n(is-even 5000)\n```\n\n### Namespaces\n\nEvery top level definition is part of a namespace\n\n```{clojure}\n(ns product.lib)\n(defn compute [a b] (+ a b))\n(ns user)\n(product.lib/compute 10 32)\n```\n\n\n### Reader Dispatch\n\nThe reader switches to a different set of interpretations of the next symbol when reading the character `#`.\n\n### `#_` ignores the next form\n\n```{clojure}\n#_ (r/stop \"error\")\n\"Yay\"\n```\n\n### R interop\n\nAll symbols starting with the namespace `r/` are treated slightly differently. You can use that to refer to external R functions and symbols. In addition keywords are interpreted as named arguments.\n\n```{clojure}\n(r/set.seed 1)\n(def rand-numbers (r/stats::rnorm :n 10))\n(r/mean rand-numbers)\n```\n\n## Design Goals\n\n* Have fun, experiment and learn :)\n* Build a clojure-like language that supports R-interop using the `r/` namespace.\n* Thus the core language should feel like clojure and support some of clojures's core\n  functions, but still make it easy to work with R's internal data structures.\n\n## Contributing\n\n* Please read the code-of-conduct and also be aware that this a fun project,\n  so things will break and progress is valued prefect code (at the moment).\n* However everyone is invited to play around with the language, learn together,\n  extend it, document things, fix bugs and propose features.\n\n## Code of Conduct\n\nPlease note that the llr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkschumacher%2Fllr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirkschumacher%2Fllr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkschumacher%2Fllr/lists"}