{"id":15498788,"url":"https://github.com/vit0rr/monkey","last_synced_at":"2025-04-22T22:19:17.091Z","repository":{"id":257162675,"uuid":"857472041","full_name":"vit0rr/monkey","owner":"vit0rr","description":"Compiler with VM for toy language Monkey written in GoLang","archived":false,"fork":false,"pushed_at":"2024-11-16T15:46:56.000Z","size":103,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T22:19:11.754Z","etag":null,"topics":["compiler","golang","interpreter","lexer","parser","repl","vm"],"latest_commit_sha":null,"homepage":"","language":"Go","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/vit0rr.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,"publiccode":null,"codemeta":null}},"created_at":"2024-09-14T18:44:48.000Z","updated_at":"2025-04-11T19:21:48.000Z","dependencies_parsed_at":"2024-09-15T04:58:28.018Z","dependency_job_id":"12b99f8c-3bec-4e36-a1e5-36e20e70abb0","html_url":"https://github.com/vit0rr/monkey","commit_stats":null,"previous_names":["vit0rr/mumu","vit0rr/monkey"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit0rr%2Fmonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit0rr%2Fmonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit0rr%2Fmonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit0rr%2Fmonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vit0rr","download_url":"https://codeload.github.com/vit0rr/monkey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250331816,"owners_count":21413104,"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":["compiler","golang","interpreter","lexer","parser","repl","vm"],"created_at":"2024-10-02T08:47:41.888Z","updated_at":"2025-04-22T22:19:17.018Z","avatar_url":"https://github.com/vit0rr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monkey\n\nMonkey is a toy programming language that is dynamically typed and has a C-like syntax. This project is an interpreter for the Monkey programming language.\n\nIt is based on the book [Writing An Interpreter In Go](https://interpreterbook.com/).\n\n## Instructions to run \n```bash\n$ go run main.go\n# or if you want to run a file\n$ go run main.go -file \u003cfilename\u003e.monkey\n```\n\nTo learn more about available commands:\n```bash\n$ go run main.go -help\n```\n\n## Features\n- [x] Mathematical expressions\n- [x] Variable bindings\n- [x] functions\n- [x] conditionals\n- [x] return statements\n- [x] higher-order functions\n- [x] closures\n- [x] integers\n- [x] booleans\n- [x] strings\n- [x] arrays\n- [x] hashes\n  \n\n## Examples:\n### Church Encoding\n```rust\nlet to_integer = fn(proc) { \n    return proc(fn(x) { return x + 1 })(0) \n};\n\nlet ZERO = fn(f) { fn(x) { x } }; \nlet ONE = fn(f) { fn(x) { f(x) } };\nlet TWO = fn(f) { fn(x) { f(f(x)) } };\nlet THREE = fn(f) { fn(x) { f(f(f(x))) } };\n\nlet EXP = fn(m) { fn(n) { m(n) } };\nlet SUCC = fn(n) { fn(f) { fn(x) { f(n(f)(x)) } } };\n\n\nputs(to_integer(TWO));\nputs(\"succ one: \", to_integer(SUCC(ONE)));\nputs(\"exp two three: \", to_integer(EXP(TWO)(THREE)));\nputs(\"number 10: \", to_integer(fn(f) { fn(x) { f(f(f(f(f(f(f(f(f(f(x)))))))))) } }));\n```\n\n### Fibonacci\n```rust\nlet fibonacci = fn(x) {\n    if (x == 0) {\n        return 0;\n    } else {\n        if (x == 1) {\n            return 1;\n        } else {\n            fibonacci(x - 1) + fibonacci(x - 2);\n        }\n    }\n};\n\nlet result = fibonacci(10);\nputs(result); // 55\n```\n\n### higher-order functions\n```rust\nlet map = fn(arr, f) {\n    let iter = fn(arr, accumulated) {\n        if (len(arr) == 0) {\n            accumulated\n        } else {\n            iter(rest(arr), push(accumulated, f(first(arr))))\n        }\n    };\n    iter(arr, []);\n};\n\nlet reduce = fn(arr, initial, f) {\n    let iter = fn(arr, result) {\n        if (len(arr) == 0) {\n            result\n        } else {\n            iter(rest(arr), f(result, first(arr)))\n        }\n    };\n    iter(arr, initial)\n};\n\nlet doubled = map([1, 2, 3, 4, 5], fn(x) {\n    return x * 2\n});\nputs((doubled)); // [2, 4, 6, 8, 10]\n\nlet sum = reduce([1, 2, 3, 4, 5], 0, fn(acc, value) {\n    return acc + value\n});\nputs(sum); // 15\n```\n\n### Closures\n```rust\nlet add = fn(a, b) { a + b; };\nlet addTwo = fn(a) { add(a, 2); };\nlet addThree = fn(a) { add(a, 3); };\nlet applyFunc = fn(a, b, func) { func(a, b); };\napplyFunc(3, 4, add); // 7\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvit0rr%2Fmonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvit0rr%2Fmonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvit0rr%2Fmonkey/lists"}