{"id":13800429,"url":"https://github.com/mpangburn/Expressions","last_synced_at":"2025-05-13T09:31:41.068Z","repository":{"id":133523169,"uuid":"115484092","full_name":"mpangburn/Expressions","owner":"mpangburn","description":"Arithmetic and logical expressions modeled and visualized using protocol-oriented binary trees. 🌳","archived":false,"fork":false,"pushed_at":"2018-02-15T05:43:46.000Z","size":3614,"stargazers_count":398,"open_issues_count":1,"forks_count":17,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-18T15:53:31.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/mpangburn.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}},"created_at":"2017-12-27T05:16:23.000Z","updated_at":"2024-09-20T06:10:12.000Z","dependencies_parsed_at":"2023-07-10T01:33:04.861Z","dependency_job_id":null,"html_url":"https://github.com/mpangburn/Expressions","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/mpangburn%2FExpressions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpangburn%2FExpressions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpangburn%2FExpressions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpangburn%2FExpressions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpangburn","download_url":"https://codeload.github.com/mpangburn/Expressions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913138,"owners_count":21983264,"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-08-04T00:01:12.516Z","updated_at":"2025-05-13T09:31:37.349Z","avatar_url":"https://github.com/mpangburn.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/mpangburn/Expressions/blob/master/Images/Banner.png?raw=true\" width=\"480\" max-width=\"90%\" alt=\"Expressions\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg\"/\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/l/doctrine/orm.svg\"/\u003e\n    \u003ca href=\"https://twitter.com/pangburnout\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/contact-@pangburnout-blue.svg?style=flat\" alt=\"Twitter: @pangburnout\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nArithmetic and logical expressions elegantly modeled and visualized using protocol-oriented binary trees with value semantics.\n\n## Features\n- [x] Model arithmetic and logical expressions using binary trees.\n- [x] Write expressions in code in the same manner as they would be written for evaluation, i.e. making full use of literals and both unary and binary operators.\n- [x] Visualize expressions by rendering image representations, which can be easily seen using the Xcode Playground QuickLook feature.\n- [x] Animate the evaluation of expressions using `UIView`s, and observe these animations using the Xcode Playground Live View feature.\n- [x] Demonstrate the power of protocol-oriented programming by creating other simple tree structures, such as binary search trees, which gain QuickLook visualization for free.\n\n## Contents\nThe principal focus of this project is to demonstrate the structure and evaluation of arithmetic and logical expressions in an elegant, expressive way. Thanks to Swift's powerful `ExpressibleBy*Literal` protocols and operator overloading, we can write code like this:\n\n```swift\nlet expression: ArithmeticExpression\u003cInt\u003e = 2*(1+3)-8/4\n```\n\nand in doing so create the full tree representing this expression, which in turn can be visualized in an Xcode Playground via QuickLook:\n\n\u003cimg src=\"https://github.com/mpangburn/Expressions/blob/master/Images/ArithmeticExpression.png?raw=true\" width=\"248\"\u003e\n\nFurthermore, we can animate the evaluation of this expression by calling `animateEvaluation(of:)` in a Playground page. We can observe this animation in the Playground's Live View:\n\n\u003cimg src=\"https://github.com/mpangburn/Expressions/blob/master/Images/ArithmeticExpression%20Evaluation.gif?raw=true\" width=\"248\"\u003e\n\nIn addition to arithmetic expressions, logical expressions can be similarly created, viewed, and animated.\n\n```swift\nlet expression: LogicalExpression = !(true || false) \u0026\u0026 false || !true\n```\n\n\u003cimg src=\"https://github.com/mpangburn/Expressions/blob/master/Images/LogicalExpression%20Evaluation.gif?raw=true\" width=\"248\"\u003e\n\nAs a simple demonstration of the power of protocol-oriented programming, I've also implemented a couple of other tree structures, including a traditional binary search tree and a red-black tree, which can be visualized with QuickLook.\n\n## Getting Started\nWhile a brief outline of the project's contents is provided in the section above, this is a Playground-based project and ultimately better demonstrated than explained:\n\n1. Clone the project.\n2. Open **Expression.xcworkspace**.\n3. Build the project.\n4. Within the Expression Playground, navigate to the ArithmeticExpression page to begin.\n5. See the magic through Xcode Playground's QuickLook and Live View features. Each Playground Page demonstrates a type of expression or other tree-based structure.\n\n## License\nExpressions is released under the MIT license. See [LICENSE](https://github.com/mpangburn/Expressions/blob/master/LICENSE) for details.\n\nIf you find this project to be a useful tool in learning or teaching expressions or binary trees, please reach out to me [on Twitter](https://twitter.com/pangburnout)--I'd love to hear from you.\n\n","funding_links":[],"categories":["Theoretical Computer Science"],"sub_categories":["Algorithms and Data Structures"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpangburn%2FExpressions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpangburn%2FExpressions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpangburn%2FExpressions/lists"}