{"id":48170184,"url":"https://github.com/clueless-skywatcher/mathlark-v2","last_synced_at":"2026-04-04T17:33:25.671Z","repository":{"id":343304122,"uuid":"837919500","full_name":"clueless-skywatcher/mathlark-v2","owner":"clueless-skywatcher","description":"MathLark V2 - Yet another CAS","archived":false,"fork":false,"pushed_at":"2026-03-09T21:10:07.000Z","size":473,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-10T00:37:22.448Z","etag":null,"topics":["algorithms","antlr4-grammar","computer-algebra","java-computer-algebra","mathematics"],"latest_commit_sha":null,"homepage":"","language":"Java","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/clueless-skywatcher.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-04T12:44:13.000Z","updated_at":"2026-03-09T21:10:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/clueless-skywatcher/mathlark-v2","commit_stats":null,"previous_names":["clueless-skywatcher/mathlark-v2"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/clueless-skywatcher/mathlark-v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clueless-skywatcher%2Fmathlark-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clueless-skywatcher%2Fmathlark-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clueless-skywatcher%2Fmathlark-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clueless-skywatcher%2Fmathlark-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clueless-skywatcher","download_url":"https://codeload.github.com/clueless-skywatcher/mathlark-v2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clueless-skywatcher%2Fmathlark-v2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31407644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"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":["algorithms","antlr4-grammar","computer-algebra","java-computer-algebra","mathematics"],"created_at":"2026-04-04T17:33:25.571Z","updated_at":"2026-04-04T17:33:25.656Z","avatar_url":"https://github.com/clueless-skywatcher.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mathlark-v2\nWelcome to MathLark, a dynamically-typed programming language cum computer algebra system written\nfully in Java.\n\nThe programming language is also called Lark and supports a range of features,\nincluding but not limited to\n- ✔️ Variable assignments\n- ✔️ Basic mathematical operations like addition, subtraction, multiplication, division and more...\n- ✔️ 40+ in-built functions encompassing lists, dictionaries, permutation groups, permutations and also colours (Yes you heard it right)!\n- ✔️ Define your own functions, or define an empty function (one that doesn't do anything). Functions are polymorphic (can be defined with different numbers of arguments)\n- ✔️ Define lists and dictionaries\n\nAnd more features to come, including:\n- ~~Polynomial expressions and manipulation~~ (This has been added already!)\n- More permutation groups and Young tableaux\n- If, Else and ElseIf statements\n- For and While loops\n\n## REPL\nMathLark also comes with a REPL that evaluates statements line by line. REPL supports almost every feature the language has to offer, **except**: \n- ❎ function definitions (with body)\n- ❎ calling defined functions\n- ❎ using return statements\n- ❎ importing functions\n\nAlso, you don't have to use semicolons in the REPL!\n\n## Setting up\nNote: This guide assumes that you have the following installed\n- Gradle\n- Java 17 or newer\n- Git\n\nClone this repository with the command\n```\ngit clone https://github.com/clueless-skywatcher/mathlark-v2.git\n```\nRun\n```\ngradle build\n```\nto start building the project. By default the build command runs several tests which can be time-consuming. You can choose to skip the tests using this command\n```\ngradle build -x test\n```\nOnce the build is done, you will find a `larkv2-x.x.x.jar` in the `build/libs` directory. You can run\n```\njava -jar build/libs/larkv2-0.0.1.jar\n```\nto run the REPL, or optionally provide a file with the .lk extension as an argument to parse the file.\n```\njava -jar build/libs/larkv2-0.0.1.jar abc.lk\n```\n## Syntax\nWhen learning a new programming language, we always start with a \"Hello World!\" program. This one is no different. Write this code in a file\n```\nPrintLn(\"Hello World!\");\n```\nthen run the aforementioned JAR on that file. The `PrintLn` function, as one would expect, prints a single line on the output.\n\nNote: Every line that is not a non-empty function definition should end with a semicolon.\n\n## Assigning Variables\nLet's say we want to declare a variable `a` with value `5` and then print `a` then one can write\n```\na := 5;\nPrintLn(a);\n```\nKeep in mind the `:=` operator, that is for assignment (not just an `=` sign as in other languages).\n\n## Declaring Empty Functions\nLet's say we want to declare an empty function (if you recall, a function with no body).\n```\n\u003cf\u003e;\n```\nTry printing the result of this function applied on an argument\n```\n\u003cf\u003e;\na := 5;\nPrintLn(f(a));\n```\nThe output should be `f(5)`\n\n## Declaring Functions with a Body\nNow let's say we want to define a function called `Add` that just adds 1 if one argument is provided, or the sum if both arguments are provided.\nWe write\n```\n\u003cAdd\u003e := {\n    (a) := {\n        Return a + 1;\n    }\n    (a, b) := {\n        c := a + b;\n        Return c;\n    }\n}\n```\n- First we declare the function name `Add`\n- Within the first pair of braces, we can write multiple definitions of the function\nbased on different numbers of arguments. Here we have 2 definitions, one for a single argument and one for 2 arguments.\n- The second pair of braces enclose the body (behaviour) of the function.\n\nIn the same file where this function was defined, now if we write\n```\nPrintLn(Add(81));\nPrintLn(Add(5, 9));\n```\nwe get\n```\n82\n14\n```\nNote: \n- Calling a function before the same is defined will throw an error. This behaviour may be changed in future releases if needed.\n- Each definition of a function should have only one return statement in the entire code block (unless within a loop or a conditional block)\n\n## Supported Data Structures\n### Lists\nLists can have elements of any type. You can construct a list with either `[]` or the `List` function. This is a valid list\n```\na := [1, 2, 3];\n```\nas well as this\n```\na := [1, \"abc\", True];\n```\nor this\n```\na := List(1, 2, 3);\n```\nLists are 0-indexed like most other languages. You can access the ith element with the `{}` operator, e.g. to get the 3rd element of the list we say\n```\nb := a{2};\n```\nLike Python, you can also provide negative indices for accessing list elements. To get the last element we can also write\n```\nb := a{-1};\n```\nNote: Till date slicing hasn't been implemented. In future releases we might look into adding this functionality.\n## Dictionaries\nA dictionary is basically a lookup that maps one expression to another. This is a valid dictionary\n```\nd := {\"a\": 1, 123: \"c\", True: False};\n``` \nLike lists, you also use the `{}` operator to access dictionary elements.\n```\nPrintLn(d{\"a\"});\nPrintLn(d{123});\nPrintLn(d{True});\n```\nAs an alternative to the `{}` operator, you can also invoke the `DictVal` function to access elements.\n```\nPrintLn(DictVal(d, \"a\"));\n```\nYou can use the `DictKeys` function to retrieve all the keys, and `DictVals` to retrieve all the values.\n\nNote for both lists and dictionaries: Multi-index access does not work directly (at the time). E.g. `a{x}{y}` will not work. This will be fixed in a future update.\n## Function Reference\n[Function Reference](https://github.com/clueless-skywatcher/mathlark-v2/wiki/Function-Reference)\n## Credits\nThis project wouldn't be possible without help/inspiration from these repositories/software:\n- Bart Kiers' Tiny Language using ANTLR4 (Symbol Scopes are directly implemented from this code): https://github.com/bkiers/tiny-language-antlr4\n- Mathematica and the Wolfram Language by Stephen Wolfram (Serves as a major source of inspiration)\n- ANTLR4 by Terence Parr\n- SageMath (for inspiring implementation of permutations and permutation groups): https://github.com/sagemath/sage\n- Sympy, the famous open-source computer algebra system: https://github.com/sympy/sympy\n- Redberry-CAS (while code from this is not directly implemented, but their code has helped implementation of permutations): https://github.com/redberry-cas/core\n- A little help from ChatGPT and Google AI Studio\n- [Koolculator-Polynomos](https://github.com/clueless-skywatcher/kc-polynomos), a CAS library of mine that I wrote earlier that also supports polynomials. The polynomial manipulation system is directly implemented from that library, which in turn is implemented using Michael Weiss' [repo](https://github.com/mlweiss/buchberger_algorithms).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclueless-skywatcher%2Fmathlark-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclueless-skywatcher%2Fmathlark-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclueless-skywatcher%2Fmathlark-v2/lists"}