{"id":13782668,"url":"https://github.com/mmniazi/lisp","last_synced_at":"2025-05-11T16:30:56.269Z","repository":{"id":90960460,"uuid":"142805062","full_name":"mmniazi/lisp","owner":"mmniazi","description":"lisp interpreter written in c","archived":false,"fork":false,"pushed_at":"2018-09-03T22:07:40.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T18:16:46.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mmniazi.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}},"created_at":"2018-07-30T00:14:20.000Z","updated_at":"2023-12-04T10:30:57.000Z","dependencies_parsed_at":"2023-07-03T21:34:06.882Z","dependency_job_id":null,"html_url":"https://github.com/mmniazi/lisp","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/mmniazi%2Flisp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmniazi%2Flisp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmniazi%2Flisp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmniazi%2Flisp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmniazi","download_url":"https://codeload.github.com/mmniazi/lisp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225068724,"owners_count":17416121,"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-03T18:01:41.167Z","updated_at":"2024-11-17T17:31:56.054Z","avatar_url":"https://github.com/mmniazi.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# Lisp Interpreter\nLisp interpreter written in C\n\n## Usage\n- Clone: `git clone https://github.com/mmniazi/lisp.git`\n- Build (required for run or repl): `make`\n- Run: `lisp my_file.lisp`\n- Repl: `lisp`\n\n## Features\n- Primitive data types and strings\n- Common operators (`+`, `-`, `*`, `/`, `\u003e`, `\u003c=`, `==` ...)\n- Comments\n- Variables\n- Flow control (`if/else`, `while`, `switch`)\n- Functions \u0026 lambdas \n- Higher order functions\n- Scopes\n- S-expressions\n- Q-expressions/lists and list operators\n- Varargs\n- Importing code\n- Error reporting and stack traces\n\n### Example Usage\n```\n; Fibonacci\n(fun {fib n} {\n  select\n    { (== n 0) 0 }\n    { (== n 1) 1 }\n    { otherwise (+ (fib (- n 1)) (fib (- n 2))) }\n})\n```\n\n## Standard Library\n### curry\nCall function with given list of args\n```\n= {params} {1 2 3}\nfun {plus x y z} {+ x y z}\n(curry plus params)\n\u003e 6\n```\n### uncurry\nCall function with single list created from args\n```\nuncurry print 1 2 3\n\u003e {1 2 3}\n```\n### do\nPerform no of actions in sequence\n```\ndo (= {x} 2) (+ x 4)\n\u003e 6\n```\n### let\nCreate a local scope\n```\nlet {do (= {x} 100) (x)}\n\u003e 100\nx\n\u003e Error: Unbound Symbol 'x'\n```\n### not/or/and\nLogical functions\n```\nor (and true false) true\n\u003e 1\n```\n### flip\nFlip arguments for currying\n```\nflip / 1 2\n\u003e 2\n```\n### comp\napply functions in sequence `(comp f g x) -\u003e f(g(x))`\n```\ncomp head last {1 2 {3 4 5}} \n```\n### fst/snd/trd\nReturn first, second or third element of list\n```\nfst {1 2 3 4}\n\u003e 1\nsnd {1 2 3 4}\n\u003e 2\ntrd {1 2 3 4}\n\u003e 3\n```\n### nth\nReturn element on nth index\n```\nnth 2 {1 2 3 4}\n\u003e 3\n```\n### last\nReturn last element of list\n```\nlast {1 2 3}\n\u003e 3\n```\n### len\nLength of list\n```\nlen {1 2 3 5}\n\u003e 4\n```\n### take\nTake N items from list\n```\ntake 2 {1 2 3 5}\n\u003e {1 2}\n```\n### drop\nDrop N items from list\n```\ndrop 2 {1 2 3 5}\n\u003e {3 5}\n```\n### split\nSplit list at Nth element\n```\nsplit 1 {1 2 3 5}\n\u003e {{1 2} {3 5}}\n```\n### elem\nCheck for presence of element\n```\nelem 5 {1 2 3 5}\n\u003e 1\nelem 9 {1 2 3 5}\n\u003e 0\n```\n### map\nCreate new list by applying function to every elem of list\n```\nfun {square x} {* x x}\nmap square {1 2 3}\n\u003e {1 4 9}\n```\n### filter\nCreate a new list of items which match the condition\n```\nfun {even x} {== (% x 2) 0}\nfilter even {1 2 3 4}\n\u003e {2 4}\n```\n### foldl\nFold left\n```\nfoldl * 1 {2 2}\n\u003e 4\n```\n### case\nswitch statement, takes zero or more (cond, body) pairs\n```\n(fun {numbers x} { case x {0 \"Zero\"} {1 \"One\"} })\n\nnumbers 0\n\u003e Zero\n```\n\n## Credits\n- Most of this repo is direct implementation of this \n[amazing book](http://www.buildyourownlisp.com/) with\nmajor difference being that I have written my own tokenizer and parser, \ninstead of using parser-combinator library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmniazi%2Flisp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmniazi%2Flisp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmniazi%2Flisp/lists"}