{"id":19212484,"url":"https://github.com/leafo/moonlisp","last_synced_at":"2025-06-20T13:35:52.405Z","repository":{"id":2278628,"uuid":"3235647","full_name":"leafo/moonlisp","owner":"leafo","description":"a Lisp that compiles to Lua","archived":false,"fork":false,"pushed_at":"2012-02-07T05:17:48.000Z","size":111,"stargazers_count":72,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T20:51:56.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://leafo.net/moonlisp","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leafo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-21T19:39:41.000Z","updated_at":"2025-04-20T17:36:37.000Z","dependencies_parsed_at":"2022-09-24T06:02:06.650Z","dependency_job_id":null,"html_url":"https://github.com/leafo/moonlisp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leafo/moonlisp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Fmoonlisp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Fmoonlisp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Fmoonlisp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Fmoonlisp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafo","download_url":"https://codeload.github.com/leafo/moonlisp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Fmoonlisp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260953742,"owners_count":23088097,"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-11-09T13:47:07.971Z","updated_at":"2025-06-20T13:35:47.393Z","avatar_url":"https://github.com/leafo.png","language":"C","readme":"# MOONLISP\n\n\u003chttp://leafo.net/moonlisp\u003e\n\nMoonLisp is a [Lisp][0] variant that compiles directly to [Lua][1] code.\n\nIt is written in [MoonScript][2] and depends on the MoonScript runtime to\ngenerate Lua code.\n\nIn addition to Lisp syntax, and some Lisp concepts, MoonLisp provides a way to\nwrite macros for Lua using S-Expressions.\n\n  [0]: http://en.wikipedia.org/wiki/Lisp_(programming_language)\n  [1]: http://www.lua.org\n  [2]: http://moonscript.org\n\n## Usage\n\nCompiling:\n\n\t$ bin/lisp.moon lisp_code.cl \u003e lua_code.lua\n\nCompile and execute with the `-r` flag:\n\n\t$ bin/lisp.moon -r hello.cl\n\n## Example\n\nHere is an example of run length compression as described in __Ansi Common Lisp__ p.37\n\n    (defun compress (x)\n      (if (consp x)\n    \t(compr (car x) 1 (cdr x))\n    \tx))\n    \n    (defun n_elts (el n)\n      (if (\u003e n 1)\n    \t(list n el)\n    \tel))\n    \n    (defun compr (el n lst)\n      (if (null lst)\n    \t(list (n_elts el n))\n    \t(let ((next (car lst)))\n    \t  (if (eql next el)\n    \t\t(compr el (+ n 1) (cdr lst))\n    \t\t(cons (n_elts el n)\n    \t\t\t  (compr next 1 (cdr lst)))))))\n    \n    (setf input '(1 1 1 0 1 0 0 0 0 1))\n\t(p (compress input))\n\nAnd here is the (ugly) code generated:\n\n\trequire(\"lisp.lib\");\n\t(function()\n\t  compress = function(x)\n\t\treturn (function()\n\t\t  if consp(x) then\n\t\t\treturn compr(x[1], 1, x[2])\n\t\t  else\n\t\t\treturn x\n\t\t  end\n\t\tend)()\n\t  end\n\t  return compress\n\tend)();\n\t(function()\n\t  n_elts = function(el, n)\n\t\treturn (function()\n\t\t  if (n \u003e 1) then\n\t\t\treturn {\n\t\t\t  n,\n\t\t\t  {\n\t\t\t\tel,\n\t\t\t\tnil\n\t\t\t  }\n\t\t\t}\n\t\t  else\n\t\t\treturn el\n\t\t  end\n\t\tend)()\n\t  end\n\t  return n_elts\n\tend)();\n\t(function()\n\t  compr = function(el, n, lst)\n\t\treturn (function()\n\t\t  if null(lst) then\n\t\t\treturn {\n\t\t\t  n_elts(el, n),\n\t\t\t  nil\n\t\t\t}\n\t\t  else\n\t\t\treturn (function()\n\t\t\t  local next = lst[1]\n\t\t\t  return (function()\n\t\t\t\tif next == el then\n\t\t\t\t  return compr(el, (n + 1), lst[2])\n\t\t\t\telse\n\t\t\t\t  return {\n\t\t\t\t\tn_elts(el, n),\n\t\t\t\t\tcompr(next, 1, lst[2])\n\t\t\t\t  }\n\t\t\t\tend\n\t\t\t  end)()\n\t\t\tend)()\n\t\t  end\n\t\tend)()\n\t  end\n\t  return compr\n\tend)();\n\t(function()\n\t  input = {\n\t\t1,\n\t\t{\n\t\t  1,\n\t\t  {\n\t\t\t1,\n\t\t\t{\n\t\t\t  0,\n\t\t\t  {\n\t\t\t\t1,\n\t\t\t\t{\n\t\t\t\t  0,\n\t\t\t\t  {\n\t\t\t\t\t0,\n\t\t\t\t\t{\n\t\t\t\t\t  0,\n\t\t\t\t\t  {\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  1,\n\t\t\t\t\t\t  nil\n\t\t\t\t\t\t}\n\t\t\t\t\t  }\n\t\t\t\t\t}\n\t\t\t\t  }\n\t\t\t\t}\n\t\t\t  }\n\t\t\t}\n\t\t  }\n\t\t}\n\t  }\n\t  return input\n\tend)()\n\tp(compress(input))\n\n\n## About\n\nby [leafo](http://leafo.net) 2012\n\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafo%2Fmoonlisp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafo%2Fmoonlisp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafo%2Fmoonlisp/lists"}