{"id":14128451,"url":"https://github.com/dnmfarrell/Lepr","last_synced_at":"2025-08-03T23:30:58.438Z","repository":{"id":149703765,"uuid":"305239637","full_name":"dnmfarrell/Lepr","owner":"dnmfarrell","description":"A tiny Lisp like written in Perl","archived":false,"fork":false,"pushed_at":"2020-10-27T13:44:24.000Z","size":85,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-16T02:24:08.521Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/dnmfarrell.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-10-19T02:14:04.000Z","updated_at":"2022-03-03T08:28:32.000Z","dependencies_parsed_at":"2024-01-31T10:09:17.120Z","dependency_job_id":null,"html_url":"https://github.com/dnmfarrell/Lepr","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/dnmfarrell%2FLepr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FLepr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FLepr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FLepr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnmfarrell","download_url":"https://codeload.github.com/dnmfarrell/Lepr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228571844,"owners_count":17938772,"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-15T16:01:44.200Z","updated_at":"2024-12-07T06:31:17.337Z","avatar_url":"https://github.com/dnmfarrell.png","language":"Perl","funding_links":[],"categories":["Perl"],"sub_categories":[],"readme":"Lepr\n====\n\"Leper\" is a tiny Lisp-like written in Perl. It supports lambdas, conditional execution and quoting. It's lazy as hell; all work is deferred to thunks until demanded.\n\nFunction parameters can use sigils to denote the type they hold, which is type-checked at run time. Lepr uses functional scoping rules.\n\nLepr is mostly \"pure\"; `set` and `print` are the only forms which don't return a value. Looping is done via recursion, symbols once set cannot be re-defined. Here I was influenced by the book [Introduction To Functional Programming](https://www.semanticscholar.org/paper/Introduction-to-functional-programming-Bird-Wadler/0e19b6c7fb5ac38f9c5cd5316f07d3b5c2d84a62) (Bird \u0026 Wadler 1st ed.). It's difficult to match the elegance of ML without pattern matching but thanks to Lisp's syntax, Lepr is quite terse.\n\nPeter Norvig's article on [Lispy](https://norvig.com/lispy.html) inspired me, I hope it inspires you too.\n\nRunning Lepr\n------------\n    echo '(print \"Hello, World!\")' | ./lepr\n    Hello, World!\n\n    ./lepr t/hello.lr\n    Hello, World!\n\nComments\n--------\nSingle line comments begin with `;`.\n\nTypes\n-----\n  * functions\n  * lists\n  * nums\n  * strings\n  * nil\n\nLogic\n-----\nThe only false value is `nil` all other values are true. `nil` is equal to an empty list, so it is both an atom and a list.\n\nMacros\n------\nCurrently only supports the quote operator `'` which is expanded into the `quote` keyword. E.g.\n\n    '(1 2 3) --\u003e (quote (1 2 3))\n\nKeywords\n--------\n    (fun (params) form...)\n    (if cond then else)\n    (set key value ...)\n    (quote form...)\n\nSigils\n------\nFunction parameters may be prefaced with a sigil to denote its type:\n\n    @ list\n    * atom\n    \u0026 function\n    # num\n    $ str\n\nThe absence of a sigil means any type is permitted. Within the function body the sigil is not used when referring to the bound argument. E.g. here is a function which accepts a number and returns it:\n\n    (fun (#x) x)\n\nBuilt-in Functions\n------------------\n    print\n    atom (x)\n    cons (*x @l)\n    car  (@l)\n    cdr  (@l)\n    eq   (x y)\n    ++   (@l @m)\n\nN.b. these satisfy the Lisp 1.5 elementary functions from the [LISP 1.5 Programmer's Manual](https://mitpress.mit.edu/books/lisp-15-programmers-manual).\n\nBinary numerical functions:\n\n    ==   (#x #y)\n    \u003e=   (#x #y)\n    \u003c=   (#x #y)\n    \u003e    (#x #y)\n    \u003c    (#x #y)\n    +    (#x #y)\n    -    (#x #y)\n    /    (#x #y)\n    *    (#x #y)\n    ^    (#x #y)\n    %    (#x #y)\n\nExamples\n--------\nThese come from Lepr's std library:\n\n    (set id    (fun (x) x)\n         \u0026\u0026    (fun (x y) (if x y nil))\n         ||    (fun (x y) (if x x y))\n         map   (fun (\u0026f @l)\n                    (set h (car l) t (cdr l))\n                    (cons (f h) (if t (map f t) '())))\n         grep  (fun (\u0026f @l)\n                     (set h (car l) t (cdr l))\n                     (++ (if (f h) (cons h '()) nil)\n                         (if t (grep f t) nil)))\n         sort  (fun (@nums)\n                    (set h (car nums)\n                         t (cdr nums)\n                         lt (if t (grep (fun (#n) (\u003c  n h)) t) nil)\n                         ge (if t (grep (fun (#n) (\u003e= n h)) t) nil))\n                    (if nums (++ (sort lt) (cons h (sort ge))) nil))\n         foldl (fun (\u0026f i @l)\n                    (set h (car l) t (cdr l))\n                    (if l (foldl f (f i h) t) i))\n         and   (fun (@l) (foldl \u0026\u0026 1 l))\n         or    (fun (@l) (foldl || nil l)))\n\nTests\n-----\nRun the test suite:\n\n    $ t/run-tests.t\n\nDependencies\n------------\nPerl 5.16 or higher.\n\nInstall\n-------\nSave the `lepr` file somewhere in your PATH.\n\nLicense\n-------\nCopyright 2020 David Farrell\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2FLepr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnmfarrell%2FLepr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2FLepr/lists"}