{"id":15668291,"url":"https://github.com/devstopfix/postfix-elixir","last_synced_at":"2025-03-30T04:42:13.659Z","repository":{"id":63891544,"uuid":"571156273","full_name":"devstopfix/postfix-elixir","owner":"devstopfix","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-11T08:47:03.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T06:49:13.228Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/devstopfix.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}},"created_at":"2022-11-27T11:00:58.000Z","updated_at":"2022-11-28T11:32:27.000Z","dependencies_parsed_at":"2023-01-14T12:15:17.295Z","dependency_job_id":null,"html_url":"https://github.com/devstopfix/postfix-elixir","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/devstopfix%2Fpostfix-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fpostfix-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fpostfix-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fpostfix-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devstopfix","download_url":"https://codeload.github.com/devstopfix/postfix-elixir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246277352,"owners_count":20751548,"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":[],"created_at":"2024-10-03T14:07:58.363Z","updated_at":"2025-03-30T04:42:13.644Z","avatar_url":"https://github.com/devstopfix.png","language":"Elixir","readme":"# Postfix\n\nSimple evaluator of a list of values and functions given in [postfix][postfix] order. \n\n```elixir\n{:ok, 20} = Postfix.eval([7, 2, \u0026-/2, 4, \u0026*/2])\n```\n\nInspired by [Factor][factor]. See [Postfix.Stack][stack] for examples.\n\n[![Hex version badge](https://img.shields.io/hexpm/v/postfix.svg)](https://hex.pm/packages/postfix)\n[![ci](https://github.com/devstopfix/postfix-elixir/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/devstopfix/postfix-elixir/actions/workflows/ci.yml)\n\n## Usage\n\nFunctions are evaluated with all the operands to their left, and the result\nreplaces the function it's operands in the list and evaluation continues.\n\nIf any function returns an `{:ok, value}` tuple then the value is unwrapped\nand used as the result.\n\nAny function that fails with an `{:error, _}` tuple short-circuits and \nbecomes the result of the evaluation.\n\nThere are two implementations:\n\n* `Postfix.Simple` for simple pipelines using a list\n* [Postfix.Stack][stack] which uses a list for the program and a stack for operands and results\n\n### Limitations\n\nIt is not possible to pass a function to a higher-order function as it will be evaluated.\n\nGiven the filter example:\n\n```elixir\nis_odd? = fn x -\u003e rem(x, 2) == 0 end\nEnum.filter(1..3, is_odd?)\n```\n\nThis *cannot* be written as:\n\n```elixir\nis_odd? = fn x -\u003e rem(x, 2) == 0 end\n\n{:ok, [2]} = Postfix.eval([1..3, is_odd?, \u0026Enum.filter/2])\n```\n\nHowever it could be written as:\n\n```elixir\nis_odd? = fn x -\u003e rem(x, 2) == 0 end\nfilter_odd = fn xs -\u003e Enum.filter(xs, is_odd?) end\n\n{:ok, [2]} = Postfix.eval([1..3, filter_odd])\n```\n\n## Installation\n\nThis package can be installed\nby adding `postfix` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:postfix, \"~\u003e 1.2\"}\n  ]\nend\n```\n\n## License\n\nCopyright 2022 J Every\n\nReleased under the [MIT License][mit]\n\n[factor]: https://factorcode.org/\n[mit]: https://opensource.org/licenses/MIT\n[postfix]: https://en.wikipedia.org/wiki/Reverse_Polish_notation\n[stack]: https://hexdocs.pm/postfix/Postfix.Stack.html","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fpostfix-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevstopfix%2Fpostfix-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fpostfix-elixir/lists"}