{"id":18989449,"url":"https://github.com/source-academy/source-programs","last_synced_at":"2025-04-22T11:09:54.308Z","repository":{"id":52560803,"uuid":"241558670","full_name":"source-academy/source-programs","owner":"source-academy","description":"Notable Source programs, developed for SICP JS and other educational projects","archived":false,"fork":false,"pushed_at":"2025-03-30T17:42:34.000Z","size":1702,"stargazers_count":7,"open_issues_count":7,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-16T22:09:17.483Z","etag":null,"topics":["hacktoberfest","source","source-academy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/source-academy.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-19T07:24:29.000Z","updated_at":"2025-03-30T17:42:37.000Z","dependencies_parsed_at":"2025-04-20T06:15:31.857Z","dependency_job_id":null,"html_url":"https://github.com/source-academy/source-programs","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/source-academy%2Fsource-programs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsource-programs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsource-programs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsource-programs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/source-academy","download_url":"https://codeload.github.com/source-academy/source-programs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250228417,"owners_count":21395958,"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":["hacktoberfest","source","source-academy"],"created_at":"2024-11-08T17:06:43.300Z","updated_at":"2025-04-22T11:09:54.272Z","avatar_url":"https://github.com/source-academy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Source Programs\n\nThis repo contains programs written in [Source](\u003chttps://en.wikipedia.org/wiki/Source_(programming_language)\u003e), developed for [SICP JS](https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs,_JavaScript_Adaptation) and other educational projects.\n\nAll programs in this repository are runnable in the [Source Academy playground](https://sourceacademy.nus.edu.sg/playground#chap=4): copy the program into the editor, choose \"Source §4\", and press \"Run\".\n\n## Evaluators\n\nThe evaluators in this section all follow the general style of SICP JS Chapter 4.\n\n- [`src/evaluators/source-0.js`](https://share.sourceacademy.nus.edu.sg/y1mpz): evaluator for Source §0 (calculator language)\n\n\n## Classics\n\nSome classic problems, solved in Source.\n\n- [`src/classics/permutations.js`](https://share.sourceacademy.nus.edu.sg/xvmtm): permutations of a list\n- [`src/classics/sorting_lists.js`](https://share.sourceacademy.nus.edu.sg/lshq5): some list sorting functions\n- [`src/classics/subsets.js`](https://share.sourceacademy.nus.edu.sg/u9vfe): compute all subsets of a list\n\n## Steppers\n\nThe steppers in this section implement a small-step semantics, following the substitution model of SICP JS Chapter 1 and 2.\n\n- [`src/steppers/source-0.js`](https://share.sourceacademy.nus.edu.sg/hnbvq): stepper for Source §0\n\n## Type checkers\n\nThe type checkers in this section follow a rule-based static semantics available in [doc/type-checking.pdf](https://github.com/source-academy/source-programs/blob/master/doc/type-checking.pdf).\n\n- [`src/type-checkers/source-0.js`](https://share.sourceacademy.nus.edu.sg/su5ha): type checker for Source §0\n\n## Virtual machines\n\nThe virtual machines in this section are SECD-style and follow a description in [doc/virtual-machines.pdf](https://github.com/source-academy/source-programs/blob/master/doc/virtual-machines.pdf). Each virtual machine comes with a compiler, implemented in the same file.\n\n- [`src/virtual-machines/source-0.js`](https://share.sourceacademy.nus.edu.sg/tn6la): virtual machine for Source §0 (calculator language)\n\n## Tool Demos\n\n(click to run; for actual sources, go to [`src/tool-demos/`](https://github.com/source-academy/source-programs/blob/master/src/tool-demos/))\n\n- [`src/tool-demos/stepper.js`](https://tinyurl.com/SICPJS-stepper): stepper tool (small-step semantics, based on substitution)\n- [`src/tool-demos/box-and-pointer-diagrams.js`](https://tinyurl.com/SICPJS-box-and-pointer): box-and-pointer diagram visualizer for pairs and lists (following SICP JS chapter 2)\n- [`src/tool-demos/environment-model.js`](https://tinyurl.com/SICPJS-env-diagram): environment model visualizer (following SICP JS chapter 3)\n\n## Module Demos\n\n(click to run; for actual sources, go to [`src/module-demos/`](https://github.com/source-academy/source-programs/blob/master/src/module-demos/))\n\n- [`src/module-demos/runes.js`](https://tinyurl.com/SICPJS-hearts): the \"picture language\" of SICP JS 2.2.4\n- [`src/module-demos/twist.js`](https://share.sourceacademy.nus.edu.sg/dy557): some fun with the \"picture language\"\n- [`src/module-demos/curves.js`](https://share.sourceacademy.nus.edu.sg/curvedemo): a \"curves\" library for drawing curves with functional programming\n- [`src/module-demos/times.js`](https://share.sourceacademy.nus.edu.sg/timestable): visual times tables using the \"curves\" library\n- [`src/module-demos/sounds.js`](https://tinyurl.com/SICPJS-siren): a \"sounds\" library for generating sounds and music, starting from their constituent sine waves\n- [`src/module-demos/bohemian.js`](https://tinyurl.com/SICPJS-rhapsody): Bohemian Rhapsody cover using the \"sounds\" library\n\n## Test framework\n\n- [`src/test/framework/main.js`](https://github.com/source-academy/source-programs/blob/master/src/test/framework/): test framework for Source programs, written in Source §4\n\n# Testing\n\n[requires bash (any version) and awk (BSD awk 20070501); does not work with gawk]\n\nFor testing your Source programs, you need `node` and `yarn`.\n\nWrite your test cases in a folder `__tests__` in each `src` subfolder. The name of the file specifies the targeted Source of your test case. For example, if `src/steppers/source-0.js` is the Source, a test case might be `src/steppers/__tests__/source-0.test1.js`.\n\nOnly the tests written will be run.\n\nEach test case is appended to your Source, and then run with `js-slang` (using Source §4). The last line of the test case is a `//` comment that must contain the expected result. For example, a stepper test case may be:\n\n```js\nparse_and_evaluate(\"! (1 === 1 \u0026\u0026 2 \u003e 3);\");\n// true\n```\n\nBefore you can run the tests, you need to install `js-slang` by typing:\n\n```sh\n% yarn\n% yarn install\n```\n\nRun all test cases by typing:\n\n```sh\n% yarn test\n```\n\nFor failure cases (where you program is to throw error, e.g. memory exhausted error for virtual machines), you can include the error message as per normal. The lastest JS-Slang already throws the error message explicitly, without letting the underlying TypeScript handling it. Hence, an error message\n\n```sh\nLine 2073: Error: memory exhausted despite garbage collection undefined\n```\n\ncan be written in the test file:\n\n```js\n// Line 2073: Error: memory exhausted despite garbage collection undefined\n```\n\nor\n\n```js\n// Error: memory exhausted despite garbage collection undefined\n```\n\nwhere only the part that starts from `Error:` will be compared. Line number is be ignored as it varies. If line number is needed for a particular reason, it can be appended to the back.\n\n\u003e Integration of the `test` script with `src/test/framework/` is pending a fix to the `--variant` parameter; any help appreciated.\n\n# License\n\n[![GPL 3][gpl3-image]][gpl3]\nAll JavaScript programs in this repository are licensed under the\n[GNU General Public License Version 3][gpl3].\n\n[gpl3]: https://www.gnu.org/licenses/gpl-3.0.en.html\n[gpl3-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/License_icon-gpl.svg/50px-License_icon-gpl.svg.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsource-programs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsource-academy%2Fsource-programs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsource-programs/lists"}