{"id":18390532,"url":"https://github.com/gitcordier/reversepolishnotationparser","last_synced_at":"2025-06-28T16:35:06.011Z","repository":{"id":112642264,"uuid":"179085768","full_name":"gitcordier/ReversePolishNotationParser","owner":"gitcordier","description":"Parses then computes RPN expressions. Iterative algorithm, not the naive one! Problem originated from http://codingdojo.org/kata/. Further reading at https://en.wikipedia.org/wiki/Reverse_Polish_notation","archived":false,"fork":false,"pushed_at":"2020-07-23T21:07:41.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T08:57:15.224Z","etag":null,"topics":["codingdojo","parser","parsing","reverse-polish-notation","rpn","rpn-calculator","rpn-expressions"],"latest_commit_sha":null,"homepage":"","language":"Python","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/gitcordier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-04-02T13:37:58.000Z","updated_at":"2022-12-01T09:46:14.000Z","dependencies_parsed_at":"2023-06-10T09:30:56.714Z","dependency_job_id":null,"html_url":"https://github.com/gitcordier/ReversePolishNotationParser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gitcordier/ReversePolishNotationParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitcordier%2FReversePolishNotationParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitcordier%2FReversePolishNotationParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitcordier%2FReversePolishNotationParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitcordier%2FReversePolishNotationParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitcordier","download_url":"https://codeload.github.com/gitcordier/ReversePolishNotationParser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitcordier%2FReversePolishNotationParser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262460541,"owners_count":23314758,"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":["codingdojo","parser","parsing","reverse-polish-notation","rpn","rpn-calculator","rpn-expressions"],"created_at":"2024-11-06T01:48:19.616Z","updated_at":"2025-06-28T16:35:05.976Z","avatar_url":"https://github.com/gitcordier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RPN\n## What is implemented\nPackage rpn encloses an implementation of computation after the RPN (Reverse\nPolish Notation, or 'postfixed notation') norm (\nsee http://codingdojo.org/kata/RPN/).\n\nWe aim at mimicking what a human does as it reads a RPN expression. \nFor instance, '1 2 + 3 +' reads off '3 3 +', which means '3 + 3' in regular \nnotation.\nThe algorithm is then iterative, straightforward, and naive: \nThere are no stack-like abstractions, nor recursive calls.\n\nHuman-readable structures (namely, dictionaries) were preferred. \nIn other words, figures like x[i][1] are discarded in favor of the more \nself-explanatory x[i]['value'].\n\n## Package Structure\n### rpn\nThe core package is rpn, which encloses the routine script rpn.py.\nWhen run, main.py loads rpn.py and eventually displays a famous numerical \nresult, computed from RPN expressions ([further reading here](https://en.wikipedia.org/wiki/Taxicab_number )).\n\n### test_rpn\ntest_rpn encloses test_rpn.py, which is a unittest script.\nTwo inputs are given: \n1. input_comfirm.json (in ./inputs): The results to comfirm.\n2. input_refute.json (in ./inputs): The results to refute.\nThose values are intentionally wrong. Any match is then an evidence that the \nimplementation is flawed. Moreover, it may reveal where the bug is.\n\nSymmetrically, two outputs are given: \n1. putput_comfirm_errors.json (in ./outputs): Keeps track of results that could\nnot be comfirmed.\n2. output_refute_erros.json (in ./outputs): Keeps track of various \nmiscomputations.\n\n## About the math\nLet us stress that numbers are indentified with constant (0-ary) operators. \nThis means that A = A(B, C, …) given any list (A, B, C, …) of numbers.\n\nIn terms of RPN, this means that any list of constants '… Z … C B A' reads off\n'A'.\n\n## Code conventions\nWe wanted the _if_, _elif_ pattern to emulate the switch one. So, this is why we \nwrote **if**, **elif**, …, **elif**, **else**. We believe that repeatedly \nwriting 'else: pass' is worth the clarity benefit: Sticking to this \nconvention makes some room for debugging and further improvements.\n\n## TODOS\nEnrich and organize the input json files. For example, enlist expressions and\nall suitable operand permutations (could be done with itertools), in order to \nprove that the parsing is stable under such permutation (e.g ' 1 2 3 + + ' \nmust be shown as equivalent to '1 3 2 + +', ' 2 1 3 + + ', and so on).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitcordier%2Freversepolishnotationparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitcordier%2Freversepolishnotationparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitcordier%2Freversepolishnotationparser/lists"}