{"id":17923723,"url":"https://github.com/deryeger/refunk","last_synced_at":"2025-04-03T09:21:37.510Z","repository":{"id":53134632,"uuid":"208084854","full_name":"DerYeger/refunk","owner":"DerYeger","description":"A library for studying primitive recursive functions with Kotlin.","archived":false,"fork":false,"pushed_at":"2021-05-10T17:10:56.000Z","size":735,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T22:44:42.065Z","etag":null,"topics":["computability","computability-theory","kotlin","math","math-library","primitive-recursive-functions","recursion","recursive-functions"],"latest_commit_sha":null,"homepage":"https://refunk.yeger.eu","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DerYeger.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}},"created_at":"2019-09-12T15:34:40.000Z","updated_at":"2021-07-16T16:23:49.000Z","dependencies_parsed_at":"2022-08-29T19:12:01.780Z","dependency_job_id":null,"html_url":"https://github.com/DerYeger/refunk","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerYeger%2Frefunk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerYeger%2Frefunk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerYeger%2Frefunk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerYeger%2Frefunk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DerYeger","download_url":"https://codeload.github.com/DerYeger/refunk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970281,"owners_count":20862518,"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":["computability","computability-theory","kotlin","math","math-library","primitive-recursive-functions","recursion","recursive-functions"],"created_at":"2024-10-28T20:45:12.191Z","updated_at":"2025-04-03T09:21:37.482Z","avatar_url":"https://github.com/DerYeger.png","language":"Kotlin","readme":"\u003cp align=\"center\"\u003e\u003cimg alt=\"REFUNK\" src=\"doc/logo.png\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.gnu.org/licenses/gpl-3.0.en.html\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/DerYeger/refunk?color=40aef6\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://jitpack.io/#eu.yeger/refunk\"\u003e\u003cimg alt=\"JitPack\" src=\"https://img.shields.io/jitpack/v/github/DerYeger/refunk?color=7963dc\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n    \u003cimg alt=\"Contributions\" src=\"https://img.shields.io/badge/contributions-welcome-da4c99?style=for-the-badge\"\u003e\n    \u003ca href=\"https://codecov.io/gh/DerYeger/refunk\"\u003e\u003cimg alt=\"Coverage\" src=\"https://img.shields.io/codecov/c/github/deryeger/refunk?color=eaa232\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://travis-ci.com/DerYeger/refunk\"\u003e\u003cimg alt=\"Build\" src=\"https://img.shields.io/travis/com/deryeger/refunk/master?color=40aef6\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n***REFUNK*** is small and lightweight library for studying and evaluating **primitive recursive functions** in Kotlin.\\\nIt provides a rich set of methods for defining functions in a more **natural** way than other functional frameworks and libraries.\n\nAn interactive playground is available at https://refunk.yeger.eu.\n\n## Installation\n\n### Gradle\n\n\u003cdetails\u003e\n\u003csummary\u003eShow instructions\u003c/summary\u003e\n\u003cpre\u003e\nallprojects {\n  repositories {\n    ...\n    maven { url 'https://jitpack.io' }\n  }\n}\n\u003c/pre\u003e\n\u003cpre\u003e\ndependencies {\n  implementation 'eu.yeger:refunk:{version}'\n}\n\u003c/pre\u003e\n\u003c/details\u003e\n\n\n### Maven\n\n\u003cdetails\u003e\n\u003csummary\u003eShow instructions\u003c/summary\u003e\n\u003cpre\u003e\n\u0026lt;repositories\u0026gt;\n  \u0026lt;repository\u0026gt;\n    \u0026lt;id\u0026gt;jitpack.io\u0026lt;/id\u0026gt;\n    \u0026lt;url\u0026gt;https://jitpack.io\u0026lt;/url\u0026gt;\n  \u0026lt;/repository\u0026gt;\n\u0026lt;/repositories\u0026gt;\n\u003c/pre\u003e\n\u003cpre\u003e\n\u0026lt;dependency\u0026gt;\n  \u0026lt;groupId\u0026gt;eu.yeger\u0026lt;/groupId\u0026gt;\n    \u0026lt;artifactId\u0026gt;refunk\u0026lt;/artifactId\u0026gt;\n  \u0026lt;version\u0026gt;{version}\u0026lt;/version\u0026gt;\n\u0026lt;/dependency\u0026gt;\n\u003c/pre\u003e\n\u003c/details\u003e\n\n## Usage\n\n### Basic functions\n\n- `val c = constant(value)` with macros `const(value)`, `zero` and `one`.\n- `val s = Successor()` with macro `successor`.\n- `val p = projection(index)` with macros `first` to `tenth`.\n\n### Composition\n\nFunction composition is handled by the `Composition` class and various wrapper methods.\n```\nval f = ... \nval g1 = ... \n...\nval gn = ...\nval myComposition = f of { g1 and ... and gn }\nval myAltComp = f(g1, ..., gn)\n```\nThe example below demonstrates simple composition using the, in this case optional, projections `first` and `second`.\n```\n// f(x, y) = 2 * (x + y)\nval f = multiplication(const(2), addition(first, second)) // `addition(first, second)` is equal to `addition`\nval result = f(10, 11) // = 42\n```\nUnary functions can be composed with `Function::andThen`.\n```\nval myComposition = myFunction andThen myUnaryFunction\n```\n\n### Recursion\n\nRecursions can be defined using multiple extension methods.\n```\nval myRecursion = recursive(myRecursiveCaseFunction) withBaseCase myBaseCaseFunction                \n...             = recursive { \n                        aFunction of anotherFunction \n                  } withBaseCase { \n                        someFunction andThen someOtherFunction \n                  }\n```\nNamed projections help using the recursion results, parameters and arguments as well.\n```          \nval addition = recursive { successor of recursionResult } withBaseCase firstBaseCaseArgument\nval predecessor = recursive { recursionParameter } withBaseCase zero\n```\n\n### Invocation\n\nThe operator `Function::invoke` evaluates the function for the given arguments.\n```\nval addTwo = successor andThen successor\nprintln(addTwo(0)) //prints 2\nprintln(addTwo(40)) //prints 42\n\nval myFunction = predecessor of addition\nprintln(myFunction(3, 40)) //prints 42\n```\n\n### Additional information\n\nMore examples and various macros can be found [here](src/main/kotlin/eu/yeger/refunk/recursive/RecursiveFunctions.kt).\n\n## Non-recursive implementations\n\n***REFUNK*** also includes non-recursive [implementations](src/main/kotlin/eu/yeger/refunk/non_recursive/NonRecursiveFunctions.kt) of commonly used functions.\\\nThey are **interchangeable** with the recursive implementations and provide **improved performance** (and less StackOverflowErrors).\\\nUsing the non-recursive implementations of macros is highly **recommended**.\n\n## Exceptions and error handling\n\n- Invoking a function will throw an `ArityException` for invalid amounts of arguments.\n- Projecting a negative index will throw a `ProjectionException`.\n- Composing functions will throw a `CompositionException` if the arity of the evaluating function and the number of provided functions do not match.\n- Invoking functions or creating constants with negative values will throw a `NaturalNumberException`.\n- Any provided method will throw an `OverflowException` if an overflow occurs during evaluation.\n\n## Disclaimer\n\nThis library is intended as a tool for studying primitive recursive functions.\\\nBecause the implementation is based on experimental Kotlin features, using them in production is not recommended.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderyeger%2Frefunk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderyeger%2Frefunk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderyeger%2Frefunk/lists"}