{"id":22981080,"url":"https://github.com/rubyworks/functor","last_synced_at":"2025-08-13T17:33:54.436Z","repository":{"id":2001699,"uuid":"2935205","full_name":"rubyworks/functor","owner":"rubyworks","description":"Higher Order Functions for Ruby","archived":false,"fork":false,"pushed_at":"2015-02-24T02:15:42.000Z","size":124,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-04-10T08:21:03.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubyworks.github.com/functor","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-07T19:55:13.000Z","updated_at":"2023-04-10T08:21:03.166Z","dependencies_parsed_at":"2022-09-16T02:23:56.645Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/functor","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Ffunctor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Ffunctor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Ffunctor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Ffunctor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/functor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229773540,"owners_count":18122031,"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-12-15T01:46:53.623Z","updated_at":"2024-12-15T01:46:54.181Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Functor\n\n[Homepage](http://rubyworks.github.com/functor) |\n[Source Code](http://github.com/rubyworks/functor) |\n[Report an Issue](http://github.com/rubyworks/functor/issues)\n\n\n## Synopsis\n\nBy definition a *Functor* is simply a first class method, but these are quite\ncommon in Ruby with the `Method`, `UnboundMethod` and `Proc` classes. So for\nRuby we define a Functor as a *Higher Order Function*. Essentially, a functor\ncan vary its behavior according to the operation applied to it. Consider the\nfollowing simplistic example.\n\n    f = Functor.new { |op, x| x.send(op, x) }\n\n    f + 1  #=\u003e 2\n    f + 2  #=\u003e 4\n    f + 3  #=\u003e 6\n    f * 1  #=\u003e 1\n    f * 2  #=\u003e 4\n    f * 3  #=\u003e 9\n\nNotice that the constructor takes a block, the first argument of which is always\nthe method operating on the functor. All subsequent arguments are optional\ndependent upon the use case.\n\nWe can also think of the Functor as an *anonymous/generic delegator*. Instead\nof having to create a specialized delegator class, a functor can be used instead.\nFunctors are perfect when the delegation required is minimal.\n\n**NOTE** Ruby functors are not the same as Haskell functors. In Ruby\nEnumerators are more akin to Haskell's idea of a functor.\n\n\n## Batteries Included\n\nIn addition to the Functor class, this library includes a dozen or so useful\ncore extensions that take advantage of the power of the functor. Have a look\nat the demo directory for a rundown on the methods available and how they\nwork.\n\n\n## Copyrights\n\nCopyright (c) 2004 Rubyworks\n\nFunctor is distributable in accordance with the *BSD-2-Clause* license.\n\nSee LICENSE.txt for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Ffunctor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Ffunctor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Ffunctor/lists"}