{"id":13648074,"url":"https://github.com/triska/lisprolog","last_synced_at":"2026-01-27T13:03:38.249Z","repository":{"id":20684822,"uuid":"23967972","full_name":"triska/lisprolog","owner":"triska","description":"Interpreter for a simple Lisp. Written in Prolog.","archived":false,"fork":false,"pushed_at":"2023-02-22T23:24:12.000Z","size":9,"stargazers_count":148,"open_issues_count":0,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-29T08:07:31.112Z","etag":null,"topics":["interpreter","lisp","prolog"],"latest_commit_sha":null,"homepage":"https://www.metalevel.at/lisprolog/","language":"Prolog","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/triska.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}},"created_at":"2014-09-12T16:23:52.000Z","updated_at":"2025-05-08T11:54:59.000Z","dependencies_parsed_at":"2022-07-23T06:30:35.044Z","dependency_job_id":"d34788d1-ddb2-49b1-85b6-67d5a81636fa","html_url":"https://github.com/triska/lisprolog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/triska/lisprolog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triska%2Flisprolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triska%2Flisprolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triska%2Flisprolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triska%2Flisprolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/triska","download_url":"https://codeload.github.com/triska/lisprolog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triska%2Flisprolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["interpreter","lisp","prolog"],"created_at":"2024-08-02T01:03:57.121Z","updated_at":"2026-01-27T13:03:38.233Z","avatar_url":"https://github.com/triska.png","language":"Prolog","funding_links":[],"categories":["Prolog"],"sub_categories":[],"readme":"\n# Interpreter for a simple Lisp, written in Prolog\n\nSome online books show how to implement simple \"Prolog\" engines in\nLisp. These engines typically assume a representation of Prolog\nprograms that is convenient from a Lisp perspective, and can't even\nparse a single proper Prolog term. Instead, they require you to\nmanually translate Prolog programs to Lisp forms that are no longer\nvalid Prolog syntax. With this approach, implementing a simple \"Lisp\"\nin Prolog is even easier (\"Lisp in Prolog in zero lines\"): Manually\ntranslate each Lisp function to a Prolog predicate with one additional\nargument to hold the original function's return value. Done. This is\npossible since a function is a special case of a relation, and\nfunctional programming is a restricted form of logic programming.\n\nHere is a bit beyond that: [**`lisprolog.pl`**](lisprolog.pl)\n\nThese 165 lines of Prolog code give you an interpreter for a simple\nLisp, *including* a parser to let you write Lisp code in its\nnatural\u0026nbsp;form.\n\nInternally, Prolog [**Definite Clause\nGrammars**](https://www.metalevel.at/prolog/dcg) are used for parsing\nLisp\u0026nbsp;code, and\n[semicontext\u0026nbsp;notation](https://www.metalevel.at/prolog/dcg#semicontext)\nis used to \u003ci\u003eimplicitly\u003c/i\u003e thread through certain arguments. This\nProlog\u0026nbsp;feature is very similar to Haskell's\u0026nbsp;\u003ci\u003emonads\u003c/i\u003e.\n\nRead [**The Power of Prolog**](https://www.metalevel.at/prolog) for\nmore information about\u0026nbsp;Prolog.\n\n\nSample queries, using Scryer Prolog:\n\n\n\u003cb\u003eAppend\u003c/b\u003e:\n\n\u003cpre\u003e\n?- run(\"                                                         \\\n                                                                 \\\n    (defun append (x y)                                          \\\n      (if x                                                      \\\n          (cons (car x) (append (cdr x) y))                      \\\n        y))                                                      \\\n                                                                 \\\n    (append '(a b) '(3 4 5))                                     \\\n                                                                 \\\n    \", Vs).\n\u003cb\u003e   Vs = [append,[a,b,3,4,5]].\u003c/b\u003e\n    \u003c/pre\u003e\n\n\u003cbr\u003e\n\u003cb\u003eFibonacci, naive version:\u003c/b\u003e\n\n\u003cpre\u003e\n?- time(run(\"                                                    \\\n                                                                 \\\n    (defun fib (n)                                               \\\n      (if (= 0 n)                                                \\\n          0                                                      \\\n        (if (= 1 n)                                              \\\n            1                                                    \\\n          (+ (fib (- n 1)) (fib (- n 2))))))                     \\\n    (fib 24)                                                     \\\n                                                                 \\\n    \", Vs)).\n\u003cb\u003e   % CPU time: 6.414s\n   Vs = [fib,46368].\u003c/b\u003e\n\u003c/pre\u003e\n\n\u003cbr\u003e\n\u003cb\u003eFibonacci, accumulating version:\u003c/b\u003e\n\n\u003cpre\u003e\n?- time(run(\"                                                    \\\n                                                                 \\\n    (defun fib (n)                                               \\\n      (if (= 0 n) 0 (fib1 0 1 1 n)))                             \\\n                                                                 \\\n    (defun fib1 (f1 f2 i to)                                     \\\n      (if (= i to)                                               \\\n          f2                                                     \\\n        (fib1 f2 (+ f1 f2) (+ i 1) to)))                         \\\n                                                                 \\\n    (fib 250)                                                    \\\n                                                                 \\\n    \", Vs)).\n\n\u003cb\u003e   % CPU time: 0.020s\n   Vs = [fib,fib1,7896325826131730509282738943634332893686268675876375].\u003c/b\u003e\n    \u003c/pre\u003e\n\n\u003cbr\u003e\n\u003cb\u003eFibonacci, iterative version:\u003c/b\u003e\n\n\u003cpre\u003e\n?- time(run(\"                                                    \\\n                                                                 \\\n    (defun fib (n)                                               \\\n      (setq f (cons 0 1))                                        \\\n      (setq i 0)                                                 \\\n      (while (\u003c i n)                                             \\\n        (setq f (cons (cdr f) (+ (car f) (cdr f))))              \\\n        (setq i (+ i 1)))                                        \\\n      (car f))                                                   \\\n                                                                 \\\n    (fib 350)                                                    \\\n                                                                 \\\n    \", Vs)).\n\n\u003cb\u003e   % CPU time: 0.021s\n   Vs = [fib,6254449428820551641549772190170184190608177514674331726439961915653414425].\u003c/b\u003e\n\u003c/pre\u003e\n\n\u003cbr\u003e\n\u003cb\u003eHigher-order programming and eval:\u003c/b\u003e\n\n\u003cpre\u003e\n?- run(\"                                                         \\\n                                                                 \\\n    (defun map (f xs)                                            \\\n      (if xs                                                     \\\n          (cons (eval (list f (car xs))) (map f (cdr xs)))       \\\n        ()))                                                     \\\n                                                                 \\\n    (defun plus1 (x) (+ 1 x))                                    \\\n                                                                 \\\n    (map 'plus1 '(1 2 3))                                        \\\n                                                                 \\\n    \", Vs).\n\u003cb\u003e   Vs = [map,plus1,[2,3,4]].\u003c/b\u003e\n\u003c/pre\u003e\n\nMore information about this interpreter is available at:\n\n[**https://www.metalevel.at/lisprolog/**](https://www.metalevel.at/lisprolog/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriska%2Flisprolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftriska%2Flisprolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriska%2Flisprolog/lists"}