{"id":20863325,"url":"https://github.com/howardabrams/rpn-calc","last_synced_at":"2026-04-19T20:36:43.202Z","repository":{"id":66137099,"uuid":"60141515","full_name":"howardabrams/rpn-calc","owner":"howardabrams","description":"A streaming calculator that computes in reverse polish notation.","archived":false,"fork":false,"pushed_at":"2016-06-01T03:49:12.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T09:34:12.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/howardabrams.png","metadata":{"files":{"readme":"README.org","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}},"created_at":"2016-06-01T03:09:12.000Z","updated_at":"2016-06-01T03:09:51.000Z","dependencies_parsed_at":"2023-04-18T10:25:04.829Z","dependency_job_id":null,"html_url":"https://github.com/howardabrams/rpn-calc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/howardabrams/rpn-calc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Frpn-calc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Frpn-calc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Frpn-calc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Frpn-calc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howardabrams","download_url":"https://codeload.github.com/howardabrams/rpn-calc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Frpn-calc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32022547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-18T05:28:33.293Z","updated_at":"2026-04-19T20:36:43.182Z","avatar_url":"https://github.com/howardabrams.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE:  RPN Calculator\n#+AUTHOR: Howard Abrams\n#+EMAIL:  howard.abrams@gmail.com\n#+DATE:   2016 May 15\n\nThe project answers a programming problem in [[https://gist.github.com/ckolbeck/33760242f760f6d82658][this gist]] about making a\nstream calculator that calculates in reverse polish notation. While the\ngist request Java, the introduction I received mentioned any language.\nI hoped using Clojure would require a shorter amount of code, and a\nresult that was easier to read.\n\n* Homework Problem\n\n  Write a reverse polish notation calculator in Java. Your calculator\n  should take a RPN statements composed of space separated integers\n  and operators (see below) on a single line from stdin and perform\n  the requested operation. In the event of unparseable input your\n  program should print a sane error message to stderr and continue. If\n  the result of a calculation is not a single integer your program\n  should print the current state of the stack. You should include unit\n  and functional tests. Please don't spend more than 2-3 hours on\n  this.\n\n  Operators:\n\n    +\n        integer addition\n    -\n        integer subtraction\n    *\n        integer multiplication\n    /\n        integer quotient\n    %\n        integer modulus\n    p\n        print: remove and print the top value on the stack\n    d\n        duplicate the value on the top of the stack\n\n* Example Session\n\n  #+BEGIN_EXAMPLE\n    6 7 +\n    13\n\n    4 -2 * 2 *\n    -16\n\n    2 3 4 + d p *\n    7\n    14\n\n    2 8 2 +\n    2 10\n\n    2 +\n    Error: insufficient input for '+' operator\n\n    2 2 r\n    Error: Couldn't parse 'r' as an integer or operator\n\n    2.5 3 +\n    Error: Couldn't parse '2.5' as an integer or operator\n  #+END_EXAMPLE\n\n* Extra Credit\n\n  Instead of taking a line at a time, accept a stream of integers and\n  operators on stdin, one per line. If a line is unparseable or would\n  put the stack into a bad state, print an error message, drop the bad\n  input, and continue on. If the program exits due to an EOF, print\n  the current state of the stack before exiting.\n* Final Thoughts\n\n  The original project required that the calculations only work with\n  Integers, so I simply called out to Clojure's built-in =read-string=\n  which the REPL uses to convert a =String= to other Clojure primitives,\n  like =Integer=, symbols, Floats, etc.\n\n  While the parser/tokenizer may create a =Float=, I ignore these during\n  the process phase.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Frpn-calc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowardabrams%2Frpn-calc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Frpn-calc/lists"}