{"id":16563732,"url":"https://github.com/nathsou/picolog","last_synced_at":"2025-10-12T14:42:17.249Z","repository":{"id":62421764,"uuid":"299808583","full_name":"nathsou/Picolog","owner":"nathsou","description":"Minimal Prolog interpreter","archived":false,"fork":false,"pushed_at":"2021-04-11T15:00:51.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-15T19:52:29.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathsou.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":"2020-09-30T04:27:55.000Z","updated_at":"2021-04-11T14:57:24.000Z","dependencies_parsed_at":"2022-11-01T17:32:06.536Z","dependency_job_id":null,"html_url":"https://github.com/nathsou/Picolog","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FPicolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FPicolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FPicolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FPicolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathsou","download_url":"https://codeload.github.com/nathsou/Picolog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241982637,"owners_count":20052535,"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-10-11T20:42:10.104Z","updated_at":"2025-10-12T14:42:17.174Z","avatar_url":"https://github.com/nathsou.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Picolog\n\n## Minimalistic prolog interpreter\n\nPicolog provides a minimal prolog\ninterpreter implementation that can be embedded in other js/ts/node/deno projects to perform logical computations.\n\n### Installation\n\nPicolog is available on [deno.land](https://deno.land/x/pico)\n\n### Usage\n\nSee the [documentation](https://doc.deno.land/https/deno.land/x/pico/mod.ts)\n\nTo launch the REPL:\n\n```bash\ndeno run -A --unstable https://deno.land/x/pico/repl/Repl.ts src.pl\n```\n\nthe --unstable flag is needed since Deno.setRaw (used by the REPL) is a new API.\n\nTo embed in a project :\n\n```typescript\nimport {\n    resolve, parse, program, query,\n    isOk, formatAnswer\n} from 'https://deno.land/x/pico/mod.ts';\n\nconst prog = parse(`\n    append([], Bs, Bs).\n    append([A|As], Bs, [A|ABs]) :- append(As, Bs, ABs).\n`, program);\n\nconst goals = parse('append(A, B, [1, 2, 3]).', query);\n\nif (isOk(prog) \u0026\u0026 isOk(goals)) {\n    // iterator of all solutions\n    const solutions = resolve(prog.value, goals.value);\n\n    for (const answer of solutions) {\n        // answer maps free variables from the query\n        // to values satisfying the rules\n        console.log(formatAnswer(answer));\n    }\n}\n\n// output:\n// A = []\n// B = [1, 2, 3]\n\n// A = [1]\n// B = [2, 3]\n\n// A = [1, 2]\n// B = [3]\n\n// A = [1, 2, 3]\n// B = []\n```\n\n### Todo\n\n- [x] support the cut operator\n- [ ] support arithmetic expressions\n- [ ] add modules\n- [ ] add a trace mode\n- [ ] compile to [WAM](https://www.wikiwand.com/fr/Warren%27s_Abstract_Machine) for better performance?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathsou%2Fpicolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathsou%2Fpicolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathsou%2Fpicolog/lists"}